Solution for wxStaticText horizontal alignment and vertical spacing problem
|Reported by:||juliansmart||Owned by:|
As discussed on wx-dev, r66452 added 2 pixels to the wxStaticText height on Windows in order to align it horizontally with text controls when using sizers.
The problem with that is the change in vertical spacing compared with 2.8 - especially when large dialogs have been carefully crafted to optimize use of space. A couple of extra pixels can multiply rapidly when using labels and controls stacked vertically. Also there must be many other layout cases where you really do want the actual, minimum height of a wxStaticText, not a fudged height for a particular use case.
So the attached patch solves it by separating out the best client size and the extra size that should be added for optimal alignment (a new GetExtraSizeForAlignment() virtual function). Sizers instruct sizer items on whether this should be added in, depending on the kind of sizer. A wxBoxSizer will want to use GetExtraSizeForAlignment() in horizontal mode, but not in vertical mode. All other sizers assume horizontal algnment is desirable.
Currently it's wxMSW specific, but it's not impossible we could find a use for it on other platforms to improve alignment.
This should cover most cases automatically with no application code changes.