mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 12:59:19 +02:00
gtk2: TGroupBox: don't use GtkLabel for GtkFrame if caption is empty - this way it paints better
git-svn-id: trunk@20289 -
This commit is contained in:
parent
50ad4d8937
commit
f71703d874
@ -79,6 +79,8 @@ type
|
|||||||
{ TGtk2WSCustomGroupBox }
|
{ TGtk2WSCustomGroupBox }
|
||||||
|
|
||||||
TGtk2WSCustomGroupBox = class(TGtkWSCustomGroupBox)
|
TGtk2WSCustomGroupBox = class(TGtkWSCustomGroupBox)
|
||||||
|
protected
|
||||||
|
class procedure SetLabel(AFrame: PGtkFrame; AText: String);
|
||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class function GetDefaultClientRect(const AWinControl: TWinControl;
|
class function GetDefaultClientRect(const AWinControl: TWinControl;
|
||||||
@ -1678,6 +1680,28 @@ end;
|
|||||||
|
|
||||||
{ TGtk2WSCustomGroupBox }
|
{ TGtk2WSCustomGroupBox }
|
||||||
|
|
||||||
|
class procedure TGtk2WSCustomGroupBox.SetLabel(AFrame: PGtkFrame; AText: String);
|
||||||
|
var
|
||||||
|
Lbl: PGtkWidget;
|
||||||
|
begin
|
||||||
|
Lbl := gtk_frame_get_label_widget(AFrame);
|
||||||
|
if (AText = '') then
|
||||||
|
begin
|
||||||
|
if Lbl <> nil then
|
||||||
|
gtk_widget_destroy(Lbl);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if Lbl = nil then
|
||||||
|
begin
|
||||||
|
Lbl := gtk_label_new(nil);
|
||||||
|
gtk_widget_show(Lbl);
|
||||||
|
end;
|
||||||
|
gtk_frame_set_label_widget(AFrame, Lbl);
|
||||||
|
Gtk2Widgetset.SetLabelCaption(PGtkLabel(Lbl), AText);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TGtk2WSCustomGroupBox.CreateHandle(
|
class function TGtk2WSCustomGroupBox.CreateHandle(
|
||||||
const AWinControl: TWinControl; const AParams: TCreateParams
|
const AWinControl: TWinControl; const AParams: TCreateParams
|
||||||
): TLCLIntfHandle;
|
): TLCLIntfHandle;
|
||||||
@ -1687,14 +1711,11 @@ var
|
|||||||
{$endif}
|
{$endif}
|
||||||
TempWidget: PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
TempWidget: PGTKWidget; // pointer to gtk-widget (local use when neccessary)
|
||||||
p : pointer; // ptr to the newly created GtkWidget
|
p : pointer; // ptr to the newly created GtkWidget
|
||||||
L : PGTKWidget;
|
|
||||||
Allocation: TGTKAllocation;
|
Allocation: TGTKAllocation;
|
||||||
WidgetInfo: PWidgetInfo;
|
WidgetInfo: PWidgetInfo;
|
||||||
begin
|
begin
|
||||||
L := gtk_label_new(AParams.Caption);
|
|
||||||
gtk_widget_show(L);
|
|
||||||
P := gtk_frame_new(nil);
|
P := gtk_frame_new(nil);
|
||||||
gtk_frame_set_label_widget(GTK_FRAME(P), GTK_WIDGET(L));
|
SetLabel(P, AParams.Caption);
|
||||||
WidgetInfo := CreateWidgetInfo(P, AWinControl, AParams);
|
WidgetInfo := CreateWidgetInfo(P, AWinControl, AParams);
|
||||||
{$if defined(GtkFixedWithWindow)}
|
{$if defined(GtkFixedWithWindow)}
|
||||||
TempWidget := CreateFixedClientWidget;
|
TempWidget := CreateFixedClientWidget;
|
||||||
@ -1779,7 +1800,7 @@ var
|
|||||||
Frame: PGtkFrame;
|
Frame: PGtkFrame;
|
||||||
Lbl: PGtkWidget;
|
Lbl: PGtkWidget;
|
||||||
begin
|
begin
|
||||||
Frame:=PGtkFrame(Pointer(AWinControl.Handle));
|
Frame := PGtkFrame(Pointer(AWinControl.Handle));
|
||||||
Lbl := gtk_frame_get_label_widget(Frame);
|
Lbl := gtk_frame_get_label_widget(Frame);
|
||||||
|
|
||||||
if Lbl <> nil then
|
if Lbl <> nil then
|
||||||
@ -1793,12 +1814,9 @@ end;
|
|||||||
|
|
||||||
class procedure TGtk2WSCustomGroupBox.SetText(const AWinControl: TWinControl;
|
class procedure TGtk2WSCustomGroupBox.SetText(const AWinControl: TWinControl;
|
||||||
const AText: string);
|
const AText: string);
|
||||||
var
|
|
||||||
AFrame: PGtkFrame;
|
|
||||||
begin
|
begin
|
||||||
if not WSCheckHandleAllocated(AWinControl, 'SetText') then Exit;
|
if not WSCheckHandleAllocated(AWinControl, 'SetText') then Exit;
|
||||||
AFrame := PGtkFrame(AWinControl.Handle);
|
SetLabel(PGtkFrame(AWinControl.Handle), AText);
|
||||||
Gtk2Widgetset.SetLabelCaption(PGtkLabel(gtk_frame_get_label_widget(AFrame)), ATExt);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Gtk2WSButton_Clicked(AWidget: PGtkWidget; AInfo: PWidgetInfo): GBoolean; cdecl;
|
function Gtk2WSButton_Clicked(AWidget: PGtkWidget; AInfo: PWidgetInfo): GBoolean; cdecl;
|
||||||
|
Loading…
Reference in New Issue
Block a user