Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-07

GTK2 GroupBox auto size

21 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Henry Vermaak

Hi

The GroupBox auto size doesn't work very well, because it doesn't take the label width into account. If the label is wider than all of the children, it will get clipped. Any reason why GetGTKDefaultWidgetSize wasn't used, like virtually everywhere else in gtk2wsstdctrls.pp?

I attach a patch that uses GetGTKDefaultWidgetSize.

Henry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gtk2-groupbox-autosize.patch
Type: text/x-diff
Size: 1606 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140704/c142b38c/attachment.bin>

Reply by email

Henry Vermaak
to Henry Vermaak
Henry Vermaak wrote 11 lines
On Fri, Jul 04, 2014 at 12:39:12PM +0100, Henry Vermaak wrote: > Hi > > The GroupBox auto size doesn't work very well, because it doesn't take > the label width into account. If the label is wider than all of the > children, it will get clipped. Any reason why GetGTKDefaultWidgetSize > wasn't used, like virtually everywhere else in gtk2wsstdctrls.pp? > > I attach a patch that uses GetGTKDefaultWidgetSize. http://bugs.freepascal.org/view.php?id=20447

Same happens on Windows. There isn't even a GetPreferredSize() member, so that probably needs to be added containing MeasureText() and some code to calculate border widths. I don't really know how the win32 widgetset works, though.

Henry

Reply by email

Vojtěch Čihák

Hi,
?
Delphi has no TGroupBox.Autosize but it has TPanel.AutoSize. 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. So it seems more a feature than a bug to me.
?
Vojt?ch?

Reply by email

zeljko
to Vojtěch Čihák
Vojt?ch ?ih?k wrote 9 lines
Hi, Delphi has no TGroupBox.Autosize but it has TPanel.AutoSize. 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. So it seems more a feature than a bug to me.

+1

zeljko

Reply by email

Henry Vermaak
to Vojtěch Čihák: ? Delphi has no TGroupBox.Autosize but it has TPanel.AutoSize. When I put children on…
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

Reply by email

Henry Vermaak
to zeljko: +1 zeljko
zeljko wrote 12 lines
On 07/04/2014 03:13 PM, Vojt?ch ?ih?k wrote: >Hi, > >Delphi has no TGroupBox.Autosize but it has TPanel.AutoSize. > >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. > >So it seems more a feature than a bug to me. +1

See my reply to Vojt?ch.

Reply by email

Juha Manninen
to Vojtěch Čihák: ? Delphi has no TGroupBox.Autosize but it has TPanel.AutoSize. When I put children on…
Vojt?ch ?ih?k wrote
So it seems more a feature than a bug to me.

To me it seems like yet another bug in Delphi.
When talking about GroupBox it is actually a missing feature in Delphi. My logic also says that if the user has set a caption and defined a control to be autosized, the text should be visible. In what situation would it be useful to cut it automatically?

And yes, automatic layout + anchors in LCL are already more advanced than the Delphi equivalent. Delphi compatibility is a lame excuse for such bugs.

I want to see it fixed! Gtk2 and Windows were mentioned. What about other widgetsets, how do they behave?

There are more bug reports for the same thing. I will find them ...

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140704/558f369f/attachment.html>

Reply by email

Vojtěch Čihák
to Juha Manninen

@?I want to see it fixed! Gtk2 and Windows were mentioned. What about other widgetsets, how do they behave? ?
Qt has this issue too (i.e. GroupBox is autosized around children, long caption is not fuly visible). ?
logic also says that if the user has set a caption and defined a?control to be autosized, the text should be visible. In what situation would it be useful to cut it automatically? ?
And what about autosized forms? I mean: why it does NOT matter with Panels and Forms but it (exclusively) matters with GroupBox. ?
Although, I am more-less neutral in this case, if it will be patched or not. ?
Vojt?ch?
?

Reply by email

Juha Manninen
to Vojtěch Čihák
Vojt?ch ?ih?k wrote
And what about autosized forms? I mean: why it does NOT matter with Panels and Forms but it (exclusively) matters with GroupBox.

Good question. I think it should matter with forms, too. OTOH, forms are typically bigger and this issue does not come up so often. With panels it is irrelevant because the caption there is not useful. At least I always make it empty and use other controls (Label) for texts. They can be anchored etc.

With GroupBox this really matters. I have pumped into this problem many times and I believe Lazarus IDE dialogs have captions cut for this same reason.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140704/87745dbb/attachment.html>

Reply by email

Juha Manninen
to Juha Manninen

I applied the patch from Henry. I hope we get LCL-Win fixed, too. Zeljan, is it ok if LCL-QT gets the same change at some point?

And yes, Panels and Forms should logically behave the same way but they are not urgent.

Juha

Reply by email

zeljko
to Juha Manninen
Juha Manninen wrote 5 lines
I applied the patch from Henry. I hope we get LCL-Win fixed, too. Zeljan, is it ok if LCL-QT gets the same change at some point? And yes, Panels and Forms should logically behave the same way but they are not urgent.

Don't know how it will behave. You should try to change it and see if it works. Especially grupboxes used by IDE.

z.

Reply by email

Henry Vermaak
to Henry Vermaak
Henry Vermaak wrote 5 lines
On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: > I applied the patch from Henry. I hope we get LCL-Win fixed, too. Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with MeasureText and some more magic to take the borders into account.

I've uploaded a patch to the bug report. The hard coded numbers don't feel very good, but I haven't found a better way of doing it. The other GetPreferredSize implementations in the file also seem to do that.

Henry

Reply by email

Henry Vermaak
to Henry Vermaak
Henry Vermaak wrote 10 lines
On Sat, Jul 05, 2014 at 01:03:19PM +0100, Henry Vermaak wrote: > On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: > > I applied the patch from Henry. I hope we get LCL-Win fixed, too. > > Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with > MeasureText and some more magic to take the borders into account. I've uploaded a patch to the bug report. The hard coded numbers don't feel very good, but I haven't found a better way of doing it. The other GetPreferredSize implementations in the file also seem to do that.

Since I can't reach the bug tracker, I'll attach the Qt patch here so Zeljan can have a look.

Henry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt-groupbox-prefsize.patch
Type: text/x-diff
Size: 1603 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140707/8cb8368c/attachment.bin>

Reply by email

zeljko
to Henry Vermaak
Henry Vermaak wrote 14 lines
On Sun, Jul 06, 2014 at 01:40:53PM +0100, Henry Vermaak wrote: > On Sat, Jul 05, 2014 at 01:03:19PM +0100, Henry Vermaak wrote: >> On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: >>> I applied the patch from Henry. I hope we get LCL-Win fixed, too. >> >> Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with >> MeasureText and some more magic to take the borders into account. > > I've uploaded a patch to the bug report. The hard coded numbers don't > feel very good, but I haven't found a better way of doing it. The other > GetPreferredSize implementations in the file also seem to do that. Since I can't reach the bug tracker, I'll attach the Qt patch here so Zeljan can have a look.

Looks good. I'll upload this patch to the issue.

zeljko

Reply by email

zeljko
to Henry Vermaak: Since I can't reach the bug tracker, I'll attach the Qt patch here so Zeljan can have a…
Henry Vermaak wrote 14 lines
On Sun, Jul 06, 2014 at 01:40:53PM +0100, Henry Vermaak wrote: > On Sat, Jul 05, 2014 at 01:03:19PM +0100, Henry Vermaak wrote: >> On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: >>> I applied the patch from Henry. I hope we get LCL-Win fixed, too. >> >> Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with >> MeasureText and some more magic to take the borders into account. > > I've uploaded a patch to the bug report. The hard coded numbers don't > feel very good, but I haven't found a better way of doing it. The other > GetPreferredSize implementations in the file also seem to do that. Since I can't reach the bug tracker, I'll attach the Qt patch here so Zeljan can have a look.

Seem that bugtracker is down.

zeljko

Reply by email

Michael Van Canneyt
to zeljko
zeljko wrote 17 lines
On 07/07/2014 01:14 PM, Henry Vermaak wrote: > On Sun, Jul 06, 2014 at 01:40:53PM +0100, Henry Vermaak wrote: >> On Sat, Jul 05, 2014 at 01:03:19PM +0100, Henry Vermaak wrote: >>> On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: >>>> I applied the patch from Henry. I hope we get LCL-Win fixed, too. >>> >>> Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with >>> MeasureText and some more magic to take the borders into account. >> >> I've uploaded a patch to the bug report. The hard coded numbers don't >> feel very good, but I haven't found a better way of doing it. The other >> GetPreferredSize implementations in the file also seem to do that. > > Since I can't reach the bug tracker, I'll attach the Qt patch here so > Zeljan can have a look. Seem that bugtracker is down.

Should be back up.

Michael.

Reply by email

zeljko
to Michael Van Canneyt
Michael Van Canneyt wrote 24 lines
On Mon, 7 Jul 2014, zeljko wrote: > On 07/07/2014 01:14 PM, Henry Vermaak wrote: >> On Sun, Jul 06, 2014 at 01:40:53PM +0100, Henry Vermaak wrote: >>> On Sat, Jul 05, 2014 at 01:03:19PM +0100, Henry Vermaak wrote: >>>> On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: >>>>> I applied the patch from Henry. I hope we get LCL-Win fixed, too. >>>> >>>> Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with >>>> MeasureText and some more magic to take the borders into account. >>> >>> I've uploaded a patch to the bug report. The hard coded numbers don't >>> feel very good, but I haven't found a better way of doing it. The >>> other >>> GetPreferredSize implementations in the file also seem to do that. >> >> Since I can't reach the bug tracker, I'll attach the Qt patch here so >> Zeljan can have a look. > > Seem that bugtracker is down. Should be back up.

hm...
APPLICATION ERROR #400

Database connection failed. Error received from database was #1040: Too many connections. ... etc

z.

Reply by email

Michael Van Canneyt
to zeljko
zeljko wrote 31 lines
On 07/07/2014 01:37 PM, Michael Van Canneyt wrote: > > > On Mon, 7 Jul 2014, zeljko wrote: > >> On 07/07/2014 01:14 PM, Henry Vermaak wrote: >>> On Sun, Jul 06, 2014 at 01:40:53PM +0100, Henry Vermaak wrote: >>>> On Sat, Jul 05, 2014 at 01:03:19PM +0100, Henry Vermaak wrote: >>>>> On Sat, Jul 05, 2014 at 02:05:10PM +0300, Juha Manninen wrote: >>>>>> I applied the patch from Henry. I hope we get LCL-Win fixed, too. >>>>> >>>>> Thanks. I'll look into lcl-win, it'll need a GetPreferredSize with >>>>> MeasureText and some more magic to take the borders into account. >>>> >>>> I've uploaded a patch to the bug report. The hard coded numbers don't >>>> feel very good, but I haven't found a better way of doing it. The >>>> other >>>> GetPreferredSize implementations in the file also seem to do that. >>> >>> Since I can't reach the bug tracker, I'll attach the Qt patch here so >>> Zeljan can have a look. >> >> Seem that bugtracker is down. > > Should be back up. hm... APPLICATION ERROR #400 Database connection failed. Error received from database was #1040: Too many connections. ... etc

I increased the number of allowed connections. Hopefully that will be enough.

Michael.

Reply by email

Juha Manninen
to zeljko: hm... APPLICATION ERROR #400 Database connection failed. Error received from database was…
zeljko wrote 7 lines
hm... APPLICATION ERROR #400 Database connection failed. Error received from database was #1040: Too many connections. ... etc

I happened to have 2 machines open when I got this error. It failed with Windows + FireFox. It worked well with Linux + QupZilla browser. Now I tested again and it works with all systems.
How can OS or browser make a difference for the server's DB connections. I don't know.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20140707/9b50572f/attachment.html>

Reply by email