mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-17 17:02:51 +08:00
Add wxSize::IsAtLeast() helper
This function is trivial but still useful and it doesn't cost much to have it.
This commit is contained in:
@@ -332,6 +332,10 @@ public:
|
||||
|
||||
bool IsFullySpecified() const { return x != wxDefaultCoord && y != wxDefaultCoord; }
|
||||
|
||||
// Check that this size object is at least as big as the other one in both
|
||||
// directions.
|
||||
bool IsAtLeast(const wxSize& sz) const { return x >= sz.x && y >= sz.y; }
|
||||
|
||||
// combine this size with the other one replacing the default (i.e. equal
|
||||
// to wxDefaultCoord) components of this object with those of the other
|
||||
void SetDefaults(const wxSize& size)
|
||||
|
||||
@@ -1037,6 +1037,14 @@ public:
|
||||
*/
|
||||
void IncTo(const wxSize& size);
|
||||
|
||||
/**
|
||||
Returns @true if this size is at least as big as the other one in both
|
||||
directions.
|
||||
|
||||
@since 3.3.0
|
||||
*/
|
||||
bool IsAtLeast(const wxSize& size) const;
|
||||
|
||||
/**
|
||||
Returns @true if neither of the size object components is equal to -1,
|
||||
which is used as default for the size values in wxWidgets (hence the
|
||||
|
||||
@@ -51,3 +51,16 @@ TEST_CASE("wxSize::Operators", "[size]")
|
||||
|
||||
CHECK( wxSize(6, 9) / 1.5 == wxSize(4, 6) );
|
||||
}
|
||||
|
||||
TEST_CASE("wxSize::Functions", "[size]")
|
||||
{
|
||||
CHECK( wxSize(10, 10).IsAtLeast(wxDefaultSize) );
|
||||
CHECK( wxSize(10, 10).IsAtLeast(wxSize()) );
|
||||
CHECK( wxSize(10, 10).IsAtLeast(wxSize(10, 5)) );
|
||||
CHECK( wxSize(10, 10).IsAtLeast(wxSize(10, 10)) );
|
||||
|
||||
CHECK_FALSE( wxSize(10, 10).IsAtLeast(wxSize(11, 10)) );
|
||||
CHECK_FALSE( wxSize(10, 10).IsAtLeast(wxSize(10, 11)) );
|
||||
CHECK_FALSE( wxSize(10, 10).IsAtLeast(wxSize(11, 11)) );
|
||||
CHECK_FALSE( wxDefaultSize.IsAtLeast(wxSize()) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user