Add wxPoint::IsFullySpecified() and SetDefaults().
These methods do the same thing as wxSize methods with the same names and are useful for the same reasons. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65259 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -524,6 +524,18 @@ public:
|
|||||||
|
|
||||||
wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; }
|
wxPoint& operator+=(const wxSize& s) { x += s.GetWidth(); y += s.GetHeight(); return *this; }
|
||||||
wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; }
|
wxPoint& operator-=(const wxSize& s) { x -= s.GetWidth(); y -= s.GetHeight(); return *this; }
|
||||||
|
|
||||||
|
// check if both components are set/initialized
|
||||||
|
bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; }
|
||||||
|
|
||||||
|
// fill in the unset components with the values from the other point
|
||||||
|
void SetDefaults(const wxPoint& pt)
|
||||||
|
{
|
||||||
|
if ( x == wxDefaultCoord )
|
||||||
|
x = pt.x;
|
||||||
|
if ( y == wxDefaultCoord )
|
||||||
|
y = pt.y;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -583,6 +583,49 @@ public:
|
|||||||
wxSize& operator *=(int factor);
|
wxSize& operator *=(int factor);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@name Defaults handling.
|
||||||
|
|
||||||
|
Test for and set non-specified wxPoint components.
|
||||||
|
|
||||||
|
Although a wxPoint is always initialized to (0, 0), wxWidgets commonly
|
||||||
|
uses wxDefaultCoord (defined as @c -1) to indicate that a point hasn't
|
||||||
|
been initialized or specified. In particular, ::wxDefaultPosition is
|
||||||
|
used in many places with this meaning.
|
||||||
|
*/
|
||||||
|
//@{
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns @true if neither of the point components is equal to
|
||||||
|
wxDefaultCoord.
|
||||||
|
|
||||||
|
This method is typically used before calling SetDefaults().
|
||||||
|
|
||||||
|
@since 2.9.2
|
||||||
|
*/
|
||||||
|
bool IsFullySpecified() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Combine this object with another one replacing the uninitialized
|
||||||
|
values.
|
||||||
|
|
||||||
|
It is typically used like this:
|
||||||
|
|
||||||
|
@code
|
||||||
|
if ( !pos.IsFullySpecified() )
|
||||||
|
{
|
||||||
|
pos.SetDefaults(GetDefaultPosition());
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
@see IsFullySpecified()
|
||||||
|
|
||||||
|
@since 2.9.2
|
||||||
|
*/
|
||||||
|
void SetDefaults(const wxSize& sizeDefault);
|
||||||
|
//@}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
x member.
|
x member.
|
||||||
*/
|
*/
|
||||||
@@ -595,7 +638,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Global istance of a wxPoint initialized with values (-1,-1).
|
Global instance of a wxPoint initialized with values (-1,-1).
|
||||||
*/
|
*/
|
||||||
wxPoint wxDefaultPosition;
|
wxPoint wxDefaultPosition;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user