Ticket #10008 (confirmed defect)
Not using negative sizes in wxBoxSizer breaks AUI layout
| Reported by: | hartwigw | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9.0 |
| Component: | wxAui | Version: | 2.9-svn |
| Keywords: | wxBoxSizer negative sizes | Cc: | jjn, biwillia76 |
| Blocked By: | Patch: | no | |
| Blocking: |
Description
Assume the following code:
wxBoxSizer boxSizerPtr(new wxBoxSizer(wxHORIZONTAL));
boxSizerPtr->Add(firstWindow,0,0,0);
boxSizerPtr->AddStretchSpacer();
boxSizerPtr->Add(secondWindow,0,0,0);
this->SetSizer(boxSizerPtr);
...
Now, if the surrounding window's horizontal size is smaller than the size of its children, namely
this->GetSize().GetWidth() < firstWindow.GetSize().GetWidth()+secondWindow.GetSize().GetWidth()
than inside the box sizer's calculation method the stretch spacer's size becomes negative (at least temporarily). The width of the stretch spacer is adjusted later to zero but the remaining calculation is done with the previously calculated negative size.
Hartwig
Patch:
--- sizer_old.cpp 2008-05-08 09:02:13.000000000 +0200
+++ sizer_new.cpp 2008-09-28 10:03:12.000000000 +0200
@@ -1750,7 +1750,7 @@
item->SetDimension( child_pos, child_size );
- pt.y += height;
+ pt.y += item->GetSize().GetHeight();
}
else
{
@@ -1788,7 +1788,7 @@
item->SetDimension( child_pos, child_size );
- pt.x += width;
+ pt.x += item->GetSize().GetWidth();
}
}
