Recent

Author Topic: Inconsistent ClientHeight for Groupboxes with Labels  (Read 802 times)

bastynator

  • New Member
  • *
  • Posts: 14
Inconsistent ClientHeight for Groupboxes with Labels
« on: July 01, 2019, 10:37:27 am »
On linux (GTK2) the ClientHeight for groupboxes seems to be inconsistent. The attached example show a form with two groupboxes that have the same height. The second groupbox contains a label.
In the FormShow-method the groupboxes have different ClientHeight.

Code: Pascal  [Select]
  1. procedure TForm1.FormShow(Sender: TObject);
  2. begin
  3.   GroupBox_Empty.Caption := 'ClientHeight = ' + IntToStr(GroupBox_Empty.ClientHeight);
  4.   GroupBox_Label.Caption := 'ClientHeight = ' + IntToStr(GroupBox_Label.ClientHeight);
  5. end;
  6.  

Does anyone has an idea how to handle (or workaround that)?

I attached the compressed project and a screenshot
« Last Edit: July 01, 2019, 10:59:09 am by bastynator »

zeljko

  • Hero Member
  • *****
  • Posts: 1090
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #1 on: July 01, 2019, 10:56:27 am »
OS ? Widgetset ?

bastynator

  • New Member
  • *
  • Posts: 14
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #2 on: July 01, 2019, 11:08:45 am »
I'm Working on Ubuntu 16.04 with the GTK2 WidgetSet.

I found the difference for the clientheight evaluation of the two groupboxes. In
Code: Pascal  [Select]
  1. class function TGtk2WSCustomGroupBox.GetDefaultClientRect
there is a gtk-call
Code: Pascal  [Select]
  1. if not GTK_WIDGET_RC_STYLE(FixedWidget) then

For the empty groupbox the gtk-call returns false -> the expression is true -> the FrameBorders will be subtracted.
For the label-groupbox the gtk-call returns true -> the expression is false -> the FrameBorders will not be subtracted.
« Last Edit: July 01, 2019, 11:12:53 am by bastynator »

bastynator

  • New Member
  • *
  • Posts: 14
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #3 on: July 03, 2019, 08:19:55 am »
Has anyone an idea why GTK_WIDGET_RC_STYLE for a fixed widget of type groupbox that contains a label returns true, but for an empty groupbox it return false?
What is the expected behavior?

The docu says, it returns true if the widget's style has been looked up through the rc mechanism.
https://developer.gnome.org/gtk2/stable/GtkWidget.html#GTK-WIDGET-RC-STYLE:CAPS
Why should that depend on a groupbox's child?

zeljko

  • Hero Member
  • *****
  • Posts: 1090
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #4 on: July 03, 2019, 08:39:31 am »
Maybe you should try to put TEdit into TGroupBox instead of TLabel and see if there's any diff.

bastynator

  • New Member
  • *
  • Posts: 14
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #5 on: July 04, 2019, 01:22:48 pm »
I put several ui components into the groupbox. But the label ist the only one (at least what i found) that somehow modifies the groupbox...

zeljko

  • Hero Member
  • *****
  • Posts: 1090
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #6 on: July 04, 2019, 02:14:14 pm »
That's pretty strange since TLabel does not have ws handle

bastynator

  • New Member
  • *
  • Posts: 14
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #7 on: July 15, 2019, 10:50:31 am »
At least i found a workaround. If the label caption is empty, the clientsize for the containing groupbox behaviors as expected.
During the OnShow-Event i then set the caption of the label.

lucamar

  • Hero Member
  • *****
  • Posts: 2147
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #8 on: July 15, 2019, 11:36:53 am »
Have you tried using TStaticTex instead of a TLabel? It may be because the lack of handle in TLabel, though it shouldn't matter.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

bastynator

  • New Member
  • *
  • Posts: 14
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #9 on: July 16, 2019, 01:08:08 pm »
TStaticText has the same effect as TLabel. Both controls lead to zero framesize of the containing groupbox.

bastynator

  • New Member
  • *
  • Posts: 14
Re: Inconsistent ClientHeight for Groupboxes with Labels
« Reply #10 on: September 30, 2019, 04:23:00 pm »
I found another useful information. The AutoSize-feature of TLabel seems to trigger the issue. Setting autosize to false during construction leads to expected clientheight of the containing groupbox.

Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   ALabel.AutoSize := False;
  4. end;  
  5.  
« Last Edit: September 30, 2019, 04:29:29 pm by bastynator »