Add wxSize::DecToIfSpecified() helper.

This is similar to DecTo() but can be used even if the wxSize argument has
some components set to -1.

Notice that we don't need IncToIfSpecified() because IncTo() already works
correctly anyhow in this case.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72342 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-08-15 23:34:15 +00:00
parent 532324df23
commit 7d17499993
2 changed files with 19 additions and 0 deletions

View File

@@ -255,6 +255,13 @@ public:
{ if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; } { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; }
void DecTo(const wxSize& sz) void DecTo(const wxSize& sz)
{ if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; } { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; }
void DecToIfSpecified(const wxSize& sz)
{
if ( sz.x != wxDefaultCoord && sz.x < x )
x = sz.x;
if ( sz.y != wxDefaultCoord && sz.y < y )
y = sz.y;
}
void IncBy(int dx, int dy) { x += dx; y += dy; } void IncBy(int dx, int dy) { x += dx; y += dy; }
void IncBy(const wxPoint& pt); void IncBy(const wxPoint& pt);

View File

@@ -873,6 +873,18 @@ public:
*/ */
void DecTo(const wxSize& size); void DecTo(const wxSize& size);
/**
Decrements this object to be not bigger than the given size ignoring
non-specified components.
This is similar to DecTo() but doesn't do anything for x or y
component if the same component of @a size is not specified, i.e. set
to ::wxDefaultCoord.
@since 2.9.5
*/
void DecToIfSpecified(const wxSize& size);
/** /**
Gets the height member. Gets the height member.
*/ */