COW cleanup patch (1583966):
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 30 Oct 2006 19:26:48 +0000 (19:26 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 30 Oct 2006 19:26:48 +0000 (19:26 +0000)
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

102 files changed:
docs/latex/wx/accel.tex
docs/latex/wx/animation.tex
docs/latex/wx/bitmap.tex
docs/latex/wx/brush.tex
docs/latex/wx/cursor.tex
docs/latex/wx/font.tex
docs/latex/wx/icon.tex
docs/latex/wx/image.tex
docs/latex/wx/metafile.tex
docs/latex/wx/object.tex
docs/latex/wx/palette.tex
docs/latex/wx/pen.tex
docs/latex/wx/region.tex
docs/latex/wx/trefcount.tex
include/wx/bitmap.h
include/wx/cocoa/bitmap.h
include/wx/dcbuffer.h
include/wx/dfb/bitmap.h
include/wx/dfb/cursor.h
include/wx/generic/accel.h
include/wx/generic/animate.h
include/wx/generic/icon.h
include/wx/generic/paletteg.h
include/wx/gtk/animate.h
include/wx/gtk/bitmap.h
include/wx/gtk/cursor.h
include/wx/gtk/region.h
include/wx/gtk1/bitmap.h
include/wx/gtk1/cursor.h
include/wx/image.h
include/wx/mac/carbon/accel.h
include/wx/mac/carbon/bitmap.h
include/wx/mac/carbon/brush.h
include/wx/mac/carbon/cursor.h
include/wx/mac/carbon/icon.h
include/wx/mac/carbon/metafile.h
include/wx/mac/carbon/palette.h
include/wx/mac/carbon/pen.h
include/wx/mac/classic/bitmap.h
include/wx/mgl/bitmap.h
include/wx/mgl/cursor.h
include/wx/mgl/palette.h
include/wx/motif/accel.h
include/wx/motif/cursor.h
include/wx/motif/icon.h
include/wx/motif/palette.h
include/wx/msw/accel.h
include/wx/msw/bitmap.h
include/wx/msw/cursor.h
include/wx/msw/icon.h
include/wx/msw/metafile.h
include/wx/msw/palette.h
include/wx/msw/pen.h
include/wx/object.h
include/wx/os2/accel.h
include/wx/os2/bitmap.h
include/wx/os2/brush.h
include/wx/os2/cursor.h
include/wx/os2/icon.h
include/wx/os2/metafile.h
include/wx/os2/palette.h
include/wx/os2/pen.h
include/wx/palmos/accel.h
include/wx/palmos/bitmap.h
include/wx/palmos/cursor.h
include/wx/palmos/metafile.h
include/wx/palmos/palette.h
include/wx/palmos/pen.h
include/wx/variant.h
include/wx/x11/bitmap.h
include/wx/x11/cursor.h
include/wx/x11/palette.h
src/common/bmpbase.cpp
src/common/image.cpp
src/common/wincmn.cpp
src/dfb/bitmap.cpp
src/dfb/cursor.cpp
src/generic/paletteg.cpp
src/generic/wizard.cpp
src/gtk/animate.cpp
src/gtk/bitmap.cpp
src/gtk/brush.cpp
src/gtk/cursor.cpp
src/gtk/region.cpp
src/gtk1/bitmap.cpp
src/gtk1/brush.cpp
src/gtk1/cursor.cpp
src/mac/carbon/bitmap.cpp
src/mac/carbon/brush.cpp
src/mac/classic/bitmap.cpp
src/mgl/bitmap.cpp
src/mgl/brush.cpp
src/mgl/cursor.cpp
src/mgl/palette.cpp
src/mgl/pen.cpp
src/msw/accel.cpp
src/msw/brush.cpp
src/msw/cursor.cpp
src/palmos/cursor.cpp
src/x11/bitmap.cpp
src/x11/brush.cpp
src/x11/cursor.cpp

index 304dbb343913c9dbca6f3f3bba8349ceb115944d..ce92692abf296003c601c9dab62cd943e9a7b372 100644 (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.
-
-
index 9e3e6df8250de072bbd6d67e1f1da5ca0aa8bd86..8b6c013d06280e2670435e8db0ecf39b2dfdb938 100644 (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}.
+
index 57eb5c05d8385fab5d619faf5bbf993c5fcd8a7f..db2d9f7ac3ffe4eb33ffb29ad5204d43954775e2 100644 (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.
 
index 63faaac73ea44076f8d17baa7bf458bc43e4707d..1f00f00b40f926ca7ff4a3a12b022be9b4c97f7b 100644 (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}
 
index a27b660288e077c17a35bcabd200c0a99b86b1f6..7a07cdd22939da19f997273b053e5ffd9665f840 100644 (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.
-
-
index 001deb82097bca97f3078c652a44ba4c7f072c0a..6d45292decfd6aa3cdc7876e1d97480c87b2fe6c 100644 (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.
 
index e1df5b3e7d58a0d168644299b76d3df6a066d83a..b1a8b244a1ba90b713d7d2c72d5512d570c0b801 100644 (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.
-
 
index 8920eea23cd2b19ada4e3befa8e762599b5d97dc..a15f1a6f7b00817aca7c723da99904dd59d728a3 100644 (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}
 
index 111e5697f7be888392fee829ad31bb5946140e72..26c0c472029ca2e3aa03821d175b96b4069f910d 100644 (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}
 
index d7c65cee43e9b72401d98cee74c39ff70226c0db..4332aa6a023481475da2fb184926292bdddf161c 100644 (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}}
index 3524bf599ffd0e4539bdbcd89d4e1fe3456cbe7d..fca6264a1e2afdfdfe4a6afdbe3029219b5e8198 100644 (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.
-
index 8f39b7809993f73eadb5af0fe0c4a83ca623c721..e4353792b591e1c824395ecff6b1e874b4efaedc 100644 (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}
 
index f12a867b8f94ec396cc9b692301958214b1b1eb1..5b2cb77be198dd881aede12eeee5ad9af457c111 100644 (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}
index 968ea172a718637a688d17bdd02a911c62cfeb07..eb280c5c78be331987e581696e6a6548e0883202 100644 (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}
index afafd319583b6681de9c27837bcd81fe2f0eb4f7..4153de3a39148e61507face9147f2ba151a89c49 100644 (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);
 
index efd4480f023675a4628c0b9d3c5d011d39eb0104..0cd2cd66b136836027190f4b50009bbf443a977e 100644 (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;
index 1b12cc6f055f47b01df3bb03cd50c75a2a850fcd..bce4780cc0854781b7fccf4bc888012319024484 100644 (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);
index 0bbda585bfc94447864a00d47f4bc7a7f9332f57..affe69eaedd16aeecf5bdb79494de9de7c3a5b12 100644 (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);
index 7ebd2e81d768925edb6a78b3ac63756688369de3..03efa522fae25a619c862c9e603eae496fd90793 100644 (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;
index 17f7e44fa47de2a2cd482dcad455e53d49bff88c..23022b061ea22bbfd2390c74defe263613dfba22 100644 (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;
 
index f0cf9bbf9f3c09e53446f575416edd8c0d66b942..fd7ee2a8240b3bd240aeb2cc3c8113d46d5fcc19 100644 (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; }
 
index 9a6976f6912aaee877aeab9f6ea3f5b7fc56a379..03ffbbef905e070b8671850bf5391a67fe58db70 100644 (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
index 63feb0a9d28a9a34a18a71ed7721c5076386e52d..6ae9287a914c316a0cb386d52338ce4641098e87 100644 (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;
 
index 56dd791cf9a44191d0f2c837368460e5d9c9b803..d9dbe1b72a0a9ac2c299364ecc4ee1aa4d4a550d 100644 (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; }
 
index 1aadd87f6d9b6e48d0519eb6ab089e6360bb5ea5..e84582519ecc1a1c5c979e5f8f8f3f48ca7ad2c5 100644 (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;
 
index f4e0f4b71cd475c6da79ec447f4fbbc80eac9ace..44d03dd747ea871a98db15674376a836751357a6 100644 (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;
 
index 3aae6270c465250d484a3472bd285f3d5641c056..71f47a47aa06c491a8717d16a955c61421cd4e7f 100644 (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)
 };
index 18e2f40f19293fb4d88ca5933d051ea39e2303fc..ecf23e114475f606b2eedd2f8681f9c73b9a8317 100644 (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;
 
index 30969ed9efde8138355f4faef4eee1c3c66fc8f9..eba3d24b1b7559f4ec059ccc332c51ba2bfd11fe 100644 (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;
 
index 21e322bf2cf71ac8eb4dd407c0775c08f159a160..b1d7eea62a89a3c29a038b8d14f68bac365806cc 100644 (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 );
index 742b460190671a96395dfb1157cbbe5892c4edad..cf0ce7692786f15f665c970099daeef7f8d9aa10 100644 (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;
 
index b2eb887ecdc72167d0bba87b16baea5305837d5f..865ee73a905fb28b752ed03d8a9dbafc381204e3 100644 (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
index 349bde4603c2f445cd1b32df94e5d8f2fc8a27b0..49528efbea0951cf85ddd69dbc72e86073af709f 100644 (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 ;
 
index 2495246c57471ae3e62a9a5f66984d1ee8a1267e..0cc9a6800a7a01b61469d8b7d0ba6b1860d0db61 100644 (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);
index 34fe306a7eb0c0771cfd5e74a82992adc485c800..2e9e0d0af93d8dca084dc7352571b8edc5d70a5e 100644 (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
index e23f826746822f32dd1aaa66f536b6f4d5c25655..da46526593f9d1da9cc7b41a1637ad1d8ebed350 100644 (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
index 538ca77eca89fe2d9ecf38afde6be96ec034ab8e..f64a6ec46e39742e6c104fc789f7368e27636566 100644 (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:
index 607bf38622355c991996a605c2d960c440e9e5df..ff6f65f12c5cdc22682cd8b8e071ca934199ec67 100644 (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) ; }
index b3997a41221062f93a883da3219f556447f5101e..3a4a28f60900a27f7bae8a6a2a926f60b9e7ef6b 100644 (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
index 25a58396b50b31fa0057805ece26904e0553859f..f794945d5497eca263b7f9aba81eba13c90606ed 100644 (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;
 
index 9cbc07a306bbbacd8ab40927f8fb8f61f9bc8c52..1b3f118b3f5da244eaacd6713285786613dc69e3 100644 (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;
 
index bc15c26da0fd4af91f777101e991f9ef74da178d..c8d46785cd6f23acaaf948a86f552eff44e58f24 100644 (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;
 
index 3de7ce764078fd34df098585d1ef474a615abde0..7753ac9d6872284c92d1c240fa856ff0081de641 100644 (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;
 
index 11366cc4dfadfae6779084018e68229974623df2..e30e1f0db407b85277ef3e84ce2d76c5ce6a546d 100644 (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;
index c22eb5e56225e1f28de1019fd580a6144e6c17a0..0be289275935b142a3a3400b1d4ad754ada67f74 100644 (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)
 };
index 4d4ae783725a53f9ad9dcff7db71a662f51b3042..47b0ae7c05b335eac140e646b517f4af1dc6f37e 100644 (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);
index f65d24664fa1d972c42c9b35d1e8ea0f98241493..236c044b0c84a835688b07b25cbbaba10cac4814 100644 (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);
index 8c73d46b290a25d327f2f5e3669fe78bbcde5c0e..4a02193bed4499d77a4e876191888dc09863e8df 100644 (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;
index 2e194f10f2a35bbb55d515e342a4ba94f3294f2a..24fb71f1d74cfd03e9035cbaccded90ea6fe1eb9 100644 (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(); }
index 8682193961c1960dbb0b2adcad5e7f943fe704c1..c4b420937ce05f4a4418404eaa3e3b38e8f62369 100644 (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; }
 
index bbfc7c71a8c31e132a0aef5083f0a3b36002a1bf..3fb6377b429b8d7f3dab70aa9425b95cc3e2c96d 100644 (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)
 };
index f302fa3574dc7b27ed8ad0d6010c277572576182..561c8ae6893009f3caa59393a03046fb6744beb9 100644 (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
index 57d5f1c0d6dff148acc84fb2de0791897d2a91db..d35cd47a2dea4339d2c79175b892b621e732b29d 100644 (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));
index c268f677b4598cd7d6f45ba48c756168dea0c13c..20f610714e50434d3e21589c9eb0df82677ef6f4 100644 (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
index a0ee7448b31e80cce869cc0a4295558d4535d8b4..819c857ee25dba1838de7a696bb5f2f85e98c3ed 100644 (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);
index b19a965bd9b3ecb2b5b0ad511b86cb9408882f69..03802ca653fe2a8cc8e6918d41b7c1a9c7b7f187 100644 (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)
index c7657279d543d5cceab9e95f4c4a3a163cdbc3af..04b160e4f78b0f94d64de040b27db2462688ff9f 100644 (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);
index e1595d8dafa547dc24680268721d1f1dc95b096a..0f465ccb5573a1295f9913b1a1df7231d9748d05 100644 (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); }
index 9c254a8353c17ba8c1151ba089014dd90e4fb44d..af4208791d177a52855ba3a32bd7d8d84f7e687d 100644 (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); }
index 41e256c552c30bc4b9e7c8b8001a19bd1a4ff8a0..66f2899ddf22863ac28845a8ad268a8ab874a588 100644 (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
index e7312893fde4891a56626bb86b88f0c5880a3ab8..f6d7f0f92edb45cec77dd42957ab50e29d52d0b1 100644 (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); }
index 233016dc124002e5c2b2f340cdee65d3692ca48f..d192842d2c546c4c6399e2db7958f1462f850c24 100644 (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); }
index 5c9b415759645cbaaccb404b47ad2a87f8d4dc62..f47b035a5fd648a860274a616c6329ef75eb8779 100644 (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);
index 983fcc0ce3d6551db0d3ee8128584702eeb15fc2..71f4d9bef96ebe3c6111d94633d9d59289a1f748 100644 (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;
index ef083421ad26b12714f1bfec04d4f7de88cfc563..f4e8a90e0d10beb9ff42248903fdea71e1b71e6d 100644 (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(); }
index 82ab410b5b40f2a0131fc048d6fda61225b95180..71a94deb7a968b7a077852b1efc9c2a76f22df7b 100644 (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)
 };
index 0229985a7a774bc698bc1f9945a617193a6de7cc..690299c08cf9c9a8487866a8b31d869b4bcbd415 100644 (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); }
index fb190c5a4a8c180348d7e2e8ddc0a3ddc9637e98..7ad901706c49a2d0739a582418d243dfff71e569 100644 (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));
index 37ecf447d3f1a5b4f84ea21d2d52c3d0357bd8da..d5483080e8ae5409822fce5c5c6456d3e27ae9c3 100644 (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.
index 9cf858f8935892dbeacda2e83e8036761e7ad602..5a3ab7be0b76d18f4fc2814c70a472b508fae647 100644 (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;
 
index 1b27f36a0549be7309933cacda14934795af69ef..3a22621bd1f49ba5deda9fae166b6508ca07fe5d 100644 (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;
 
index 8375bbd624aaba25b4984aec972f1d5af8901dc8..8babcd8f594517f5bc8fd495f65a50afb8bc42e7 100644 (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);
index 82bb30b7ab3a596cc25ad97a33758e3aac54be9c..8c940d21b0dbc08eac4badad202400aa313fafab 100644 (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
 
 // ----------------------------------------------------------------------------
index a2674529dec0bd15c7957f82aeb64b074f7c5971..41d7b5e05cfa014374abf4439ac71efbfe2286ec 100644 (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
 
 //-----------------------------------------------------------------------------
index 421497abad33eee225202b326510e29268bac5f4..d03c8cb8785669d3d4df60a3893447b6f48c334f 100644 (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;
index 59d158d517ffe37f9810da77b325ffa0c3db64f4..8b57fb96deaf2da115d76923ae9d71e97d31389b 100644 (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;
 
index 5f4ea9114b356b424e6a74f4cff72891ddc1286e..c5465f52fceac5dcf6e7f07be06a6f309e851a8f 100644 (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;
index 5d21a8b33053323b28022043405d9622055e921f..ac8cd8a83bf522d9b2f473c5b9ac44cb4d1cf214 100644 (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);
index cb3b8d0f380c2a48d3bb996fc10fda9831f577f9..138f1c6680fb63680f18c815680ebd550b0fd0ff 100644 (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
index 23b88a192da725945379d54ce6985abce26df537..e2c1333636f2035c8edf55c4f75a952700df616e 100644 (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
index 522e383b8995c0c81e53d733b6f91fde0928a3f8..37cf202e56bf05b20825ef2feda0b5a5a0da7968 100644 (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) &&
index 214007898251e7ec0cf4cb692ebcb3518a952ba8..1cc7e69e1f7dc0577981c82129c61ef86604a79e 100644 (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);
     }
 
index 26b1bc06295b99b71bf985de13018df7fdb8633a..aa71d2490f32355f32e4735bf2251d48a1cff1fb 100644 (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);
index 91eecba5e4bd3dae81ff755a7ccb85626bdedbdd..57b6b02ffc0b8df714eda6b46a80b37c2ed26bc3 100644 (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; }
+    Init();
+    Reset();
+}
 
-    wxRect *m_rects;
-    size_t  m_numRects;
-};
+wxRegionIterator::wxRegionIterator( const wxRegion& region )
+{
+    Init();
+    Reset(region);
+}
 
-wxRIRefData::~wxRIRefData()
+void wxRegionIterator::Init()
 {
-    delete [] m_rects;
+    m_rects = NULL;
+    m_numRects = 0;
 }
 
-void wxRIRefData::CreateRects( const wxRegion& region )
+wxRegionIterator::~wxRegionIterator()
 {
-    delete [] m_rects;
+    wxDELETEA(m_rects);
+}
 
-    Init();
+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;
 }
index 1e7534bcc2c80ff05b310f6be3e10ee27a15d32f..9698b4640c20a5f62f8940075b21a540791a760d 100644 (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;
 }
 
index 392418c11e77db11adc06a6ce59e42df63b8073f..25536d5518c553eac84c2240386e6cb3425fb5f9 100644 (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);
     }
 
index 4f4ab1af4a860520ee13c654dbe78093d80e33b4..bd1e6ca2bd6535d3f8820d88c665900fc46870e7 100644 (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);
index 42031fe4ab52db3709267ac7abaa5f6dc74986bb..4c0a49334f344e01c6cc66a4d5ae1ee789a8ab05 100644 (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;
 
index 88dd4bc8deacf5e35dce4a85f39fc357fae7d2f2..c9dcbde97c9a6ca8986d4e02712505871ed50c65 100644 (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 );
+}
index 768b729616f0ac6039d933591b976785716c7333..0605fc91758b1bb8b3db98f579e0d730c458d91c 100644 (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;
 }
 
index a1a9c5695fe3dbbf263e279d53792d31b22a7c0f..d8396837c4da5146624bc10e19b1a5f349eb71e7 100644 (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;
 }
index 9415eea4487c04f8494e6deb4a316aacaa1d1cdc..d97544d123efefa6c89c51ef08ea790a095c369a 100644 (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
index 709b59e34f341f94e25fcfd6366814c77656e59e..5b9c7899d1e3b201ee01259d6308d174fc06b55c 100644 (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);
index da815d8ab100205e4ec5ef8702c1bd29a7d19cc1..48717b498b331eb183f16e3efbce4b3bc70dccda 100644 (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);
index 4c63041cbfd62b6975c6223fe8d80254c56ac37c..5879052da596f7efada4ef8e602688346b628602 100644 (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
index b1451eedfe71bd53247412bc7890e63a5a0fb555..3b8355d05719bcdb4fce2a53e482b8083472aa58 100644 (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));
index 5e49333dc036dd26480766b4d759118d1014b017..eb3c21d0024440451b562da2515d202c646a2e87 100644 (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)
index cdc7992e51cd0ac52a5143c88024f8293b436977..998ec54bcea798a1fd4d87bfdfcce7dd59a5c988 100644 (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;
index a51fcc0d0f8e03ad61cffaac48ec4f6b5f2ab7f8..9bb3776db3a9f57db8950d79e7e47a8f5cb8121d 100644 (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;
index 7e42116984e8ac6625a55de63e9977b3f159181e..40f925df43c80f503337fb1d9d03d863497711e2 100644 (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;
 }
index 685c12b74740aca2040390b46239cc47085bea45..9aeb1581151e2c7455af9aff8976e26605edf423 100644 (file)
@@ -42,7 +42,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);
     }
 
index bd861353d6082de93f9ccb259112793f0781e66b..fb29364b43409cf987cda0da7d7d49851d555c58 100644 (file)
@@ -141,16 +141,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);