Lazarus

Programming => LCL => Topic started by: bastynator on July 01, 2019, 10:37:27 am

Title: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: zeljko on July 01, 2019, 10:56:27 am
OS ? Widgetset ?
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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.
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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?
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: zeljko 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.
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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...
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: zeljko on July 04, 2019, 02:14:14 pm
That's pretty strange since TLabel does not have ws handle
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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.
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: lucamar 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.
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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.
Title: Re: Inconsistent ClientHeight for Groupboxes with Labels
Post by: bastynator 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.  
TinyPortal © 2005-2018