[Lazarus] GTK2 GroupBox auto size

Henry Vermaak henry.vermaak at gmail.com
Fri Jul 4 15:34:57 CEST 2014


On Fri, Jul 04, 2014 at 03:13:19PM +0200, Vojtěch Čihák wrote:
> Hi,
>  
> Delphi has no TGroupBox.Autosize but it has TPanel.AutoSize.

I really don't care about Delphi.  If I did I would be using it.

> When I put children on Panel, set very long Panel.Caption and
> Panel.AutoSize:=True then panel shrinks to the smallest possible size
> (around children) ignoring its own Caption.

I haven't seen anyone use a Panel with a caption and children.  The
caption is useless for exactly the reason you point out.  You can at
least get around it by putting a label inside the panel.

> So it seems more a feature than a bug to me.

I have software that's translatable, I've set my TRadioGroup size
manually (because AutoSize doesn't work) to accommodate the English
translation.  Now I change the translation to another language, but the
caption is now longer, so it gets clipped.  You call this a feature?  My
users don't agree with you.

Now I need to manually calculate the minimum size of the control based
on the length of the text in the current translation.  I also need to
factor in borders, themes, etc.  That's exactly the type of problem that
AutoSize sets out to solve, since all this information is already in the
widget set.

The same happens if the theme changes and the font size gets increased.
Delphi has this massive design flaw because it's based on absolute
positions and dimensions.  Lazarus goes a long way to fix this by the
AutoSize and anchoring mechanisms.

Henry




More information about the Lazarus mailing list