+wxRect& wxRect::Union(const wxRect& rect)
+{
+ // ignore empty rectangles: union with an empty rectangle shouldn't extend
+ // this one to (0, 0)
+ if ( !width || !height )
+ {
+ *this = rect;
+ }
+ else if ( rect.width && rect.height )
+ {
+ int x1 = wxMin(x, rect.x);
+ int y1 = wxMin(y, rect.y);
+ int y2 = wxMax(y + height, rect.height + rect.y);
+ int x2 = wxMax(x + width, rect.width + rect.x);
+
+ x = x1;
+ y = y1;
+ width = x2 - x1;
+ height = y2 - y1;
+ }
+ //else: we're not empty and rect is empty
+
+ return *this;
+}
+