[wx-dev] [all] should SetSize() respect size hints?
Robin Dunn
robin at alldunn.com
Tue Feb 12 17:09:31 PST 2008
Vadim Zeitlin wrote:
> On Tue, 12 Feb 2008 16:37:49 -0800 Robin Dunn <robin at alldunn.com> wrote:
>
> RD> but there is also the case of passing an explicit size is passed to the
> RD> widget's ctor. Then that value, (or partial value, like (50,-1)) is
> RD> set as the minsize, and that code will always happen before the item is
> RD> added to a sizer.
>
> I forgot about SetMinSize() call in SetInitialSize(). I think we'll just
> need to remove it and maybe modify the sizers to use the initial size of
> the window as its min size by default.
IIRC, that is how the sizers behaved before some time in the 2.5.x
series. Then we added (or perhaps just re-emphasized) the best size
concept, and then we found that there are definitely times when you want
something to be smaller than its default best size because a lot of
existing layouts broke, so we made the sizers be aware of and use the
widget's min size value and then later we added the code of setting the
initial size to be the min size. That's quite an evolution. :-)
> OTOH I'm not sure if it's really
> such a great idea to do it, what if you want to make the window bigger
> initially but still allow squeezing it to smaller size if really necessary?
We can't really do that today, so it probably isn't necessary.
Currently if a widget has a minsize then that takes precedence in the
sizer and that size (or partial size) will be used for all layout
calculations instead of the best size in the dimensions that are set in
the minsize. The current size is never used by the sizer unless a
widget's DoGetBestSize happens to use it.
You may want to give some thought to keeping a data member for the
initial size passed to the ctor. That way it can still be blended with
the current best size like minsize is now if a -1 is used for one of the
dimensions. It's probably a corner case, but that would take care of
when the best size is dynamic in the unspecified dimension based on the
content of the widget. If that partial initial size is not saved then
the default size in the unspecified dimension will be set to the current
best size, and that could change later if content is added.
Another thing to consider what to do about the <minsize> values in
existing XRC layouts, especially if the object also has a <size> value.
Even if we break some C++ compatibility I'm sure we don't want to
break people's layouts that they already have done in XRC.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wx-dev
mailing list