LCL-Gtk2: fixed centering of multiline captions for TButton, TToggleBox and TBitBtn, issue #41696

This commit is contained in:
Maxim Ganetsky 2025-06-11 23:03:00 +03:00
parent 66fcf7cad5
commit 305c953532
2 changed files with 18 additions and 0 deletions

View File

@ -169,6 +169,8 @@ begin
if ImageWidget <> nil then
g_object_unref(ImageWidget);
if LabelWidget <> nil then
gtk_label_set_justify(PGtkLabel(LabelWidget), GTK_JUSTIFY_CENTER);
ABitBtnInfo^.LabelWidget := LabelWidget;
end;

View File

@ -350,6 +350,7 @@ type
TGtk2WSToggleBox = class(TWSToggleBox)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLHandle; override;
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
end;
{ TGtk2WSRadioButton }
@ -2563,6 +2564,7 @@ begin
{ Creates the button and inserts it into the EventBox }
BtnWidget := gtk_button_new_with_label('button');
gtk_label_set_justify(PGtkLabel(PGtkBin(BtnWidget)^.Child), GTK_JUSTIFY_CENTER);
gtk_container_add(PGtkContainer(EventBox), BtnWidget);
gtk_widget_show_all(EventBox);
@ -2885,6 +2887,20 @@ begin
TGtk2WSCustomCheckBox.SetCallbacks(Widget, WidgetInfo);
end;
class procedure TGtk2WSToggleBox.SetFont(const AWinControl: TWinControl;
const AFont: TFont);
var
LblWidget: PGtkWidget;
begin
if not AWinControl.HandleAllocated then exit;
inherited SetFont(AWinControl, AFont);
LblWidget := PGtkBin({%H-}PGtkWidget(AWinControl.Handle))^.Child;
if LblWidget <> nil then
gtk_label_set_justify(PGtkLabel(LblWidget), GTK_JUSTIFY_CENTER);
end;
{ TGtk2WSCustomStaticText }
class function TGtk2WSCustomStaticText.GetLabelWidget(AFrame: PGtkFrame): PGtkLabel;