Fix wxSlider::SetSize(-1, -1, -1, -1) under Mac

Instead of doing basically nothing, this call completely mislaid out the
control as -1 were used used literally instead of meaning "use the
current geometry", as they're supposed to. Fix this by handling
arguments with the value of -1 specially.

Such call was done by wxCompositeWindow::SetLayoutDirection() used by
the widgets sample and explained why the slider couldn't be seen when
switching to its page in this sample.

Closes #18442.
This commit is contained in:
Vadim Zeitlin
2019-10-22 19:28:02 +02:00
parent 8587a96d70
commit ed57a9ab7b

View File

@@ -401,6 +401,24 @@ wxSize wxSlider::DoGetBestSize() const
void wxSlider::DoSetSize(int x, int y, int w, int h, int sizeFlags)
{
if ( w == -1 || h == -1 ||
(!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) && (x == -1 || y == -1)) )
{
const wxRect currentRect = GetRect();
if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
{
if ( x == -1 )
x = currentRect.x;
if ( y == -1 )
y = currentRect.y;
}
if ( w == -1 )
w = currentRect.width;
if ( h == -1 )
h = currentRect.height;
}
int minValWidth, maxValWidth, textheight;
int width = w;