diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2024-12-24 12:41:48 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2025-11-27 19:39:51 +0100 |
| commit | 1b2b4bb4f3ecc034a6e9364d8768e50b167a9680 (patch) | |
| tree | 065ddde53b64f7957a30b7dc9d83a748f309868c /UCoreClasses.pas | |
| parent | b9703b29819b619037cc282d719c187e51bacd30 (diff) | |
| download | tuxcmd-1b2b4bb4f3ecc034a6e9364d8768e50b167a9680.tar.xz | |
Rough GTK3 port
Diffstat (limited to 'UCoreClasses.pas')
| -rw-r--r-- | UCoreClasses.pas | 167 |
1 files changed, 1 insertions, 166 deletions
diff --git a/UCoreClasses.pas b/UCoreClasses.pas index f4b8579..7a4a43a 100644 --- a/UCoreClasses.pas +++ b/UCoreClasses.pas @@ -21,7 +21,7 @@ unit UCoreClasses; interface -uses gtk2, lazglib2, lazgobject2, SysUtils, Classes, ULibc, IniFiles, GTKStdCtrls, GTKPixbuf; +uses lazglib2, lazgobject2, lazgtk3, SysUtils, Classes, ULibc, IniFiles, GTKStdCtrls, GTKPixbuf; type TSystemUser = class public @@ -55,43 +55,6 @@ type TSystemUser = class procedure UpdateFile; override; end; - TGTKImageButton = class(TGTKButton) - private - FHBox: PGtkWidget; - FLabel: PGtkWidget; - FImage: PGtkWidget; - FEventBoxLeft, FEventBoxRight: PGtkWidget; - function GetCaption: string; - procedure SetCaption(Value: string); - procedure SetIcon(Value: TGDKPixbuf); - procedure SetSpacing(Value: integer); - public - procedure SetFromStock(Stock_ID: string; IconSize: TGTKIconSize); - published - constructor Create(AOwner: TComponent); override; - constructor CreateWithoutLabel(AOwner: TComponent); - property Caption: string read GetCaption write SetCaption; - property Icon: TGDKPixbuf write SetIcon; - property Spacing: integer write SetSpacing; - end; - - TGTKImageToggleButton = class(TGTKToggleButton) - private - FHBox: PGtkWidget; - FLabel: PGtkWidget; - FImage: PGtkWidget; - function GetCaption: string; - procedure SetCaption(Value: string); - procedure SetIcon(Value: TGDKPixbuf); - public - procedure SetFromStock(Stock_ID: string; IconSize: TGTKIconSize); - published - constructor Create(AOwner: TComponent); override; - constructor CreateWithoutLabel(AOwner: TComponent); - property Caption: string read GetCaption write SetCaption; - property Icon: TGDKPixbuf write SetIcon; - end; - implementation @@ -215,134 +178,6 @@ begin end; (********************************************************************************************************************************) -(********************************************************************************************************************************) -constructor TGTKImageButton.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - FWidget := gtk_button_new; - FLabel := gtk_label_new(''); - FImage := gtk_image_new; - FHBox := gtk_hbox_new(False, 2); - FEventBoxLeft := gtk_vbox_new(false, 0); - FEventBoxRight := gtk_vbox_new(false, 0); - gtk_box_pack_start(PGtkBox(FHBox), FEventBoxLeft, False, False, 0); - gtk_box_pack_start(PGtkBox(FHBox), FImage, False, False, 0); - gtk_box_pack_start(PGtkBox(FHBox), FLabel, True, True, 0); - gtk_box_pack_start(PGtkBox(FHBox), FEventBoxRight, False, False, 0); - gtk_container_add(PGtkContainer(FWidget), FHBox); - g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); - gtk_widget_show(FLabel); - gtk_widget_show(FImage); - gtk_widget_show(FHBox); - gtk_widget_show(FEventBoxLeft); - gtk_widget_show(FEventBoxRight); - Show; -end; - -constructor TGTKImageButton.CreateWithoutLabel(AOwner: TComponent); -begin - inherited Create(AOwner); - FWidget := gtk_button_new; - FLabel := gtk_label_new(''); - FImage := gtk_image_new; - FHBox := gtk_hbox_new(False, 2); - FEventBoxLeft := gtk_vbox_new(false, 0); - FEventBoxRight := gtk_vbox_new(false, 0); - gtk_box_pack_start(PGtkBox(FHBox), FEventBoxLeft, False, False, 0); - gtk_box_pack_start(PGtkBox(FHBox), FImage, False, False, 0); - gtk_box_pack_start(PGtkBox(FHBox), FEventBoxRight, False, False, 0); - gtk_container_add(PGtkContainer(FWidget), FHBox); - g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); - gtk_widget_show(FLabel); - gtk_widget_show(FImage); - gtk_widget_show(FHBox); - gtk_widget_show(FEventBoxLeft); - gtk_widget_show(FEventBoxRight); - Show; -end; - -function TGTKImageButton.GetCaption: string; -begin - Result := gtk_label_get_text(PGtkLabel(FLabel)); -end; - -procedure TGTKImageButton.SetCaption(Value: string); -begin - gtk_label_set_text_with_mnemonic(PGtkLabel(FLabel), PChar(Value)); -end; - -procedure TGTKImageButton.SetIcon(Value: TGDKPixbuf); -begin - if Assigned(Value) and Assigned(Value.FPixbuf) then - gtk_image_set_from_pixbuf(PGtkImage(FImage), Value.FPixbuf); -end; - -procedure TGTKImageButton.SetFromStock(Stock_ID: string; IconSize: TGTKIconSize); -begin - gtk_image_set_from_stock(PGtkImage(FImage), PChar(Stock_ID), Ord(IconSize)); -end; - -procedure TGTKImageButton.SetSpacing(Value: integer); -begin - gtk_widget_set_size_request(FEventBoxLeft, Value, -1); - gtk_widget_set_size_request(FEventBoxRight, Value, -1); -end; - - -(********************************************************************************************************************************) -(********************************************************************************************************************************) -constructor TGTKImageToggleButton.Create(AOwner: TComponent); -begin - inherited Create(AOwner); - FWidget := gtk_toggle_button_new; - FLabel := gtk_label_new(''); - FImage := gtk_image_new; - FHBox := gtk_hbox_new(False, 2); - gtk_box_pack_start(PGtkBox(FHBox), FImage, False, False, 0); - gtk_box_pack_start(PGtkBox(FHBox), FLabel, True, True, 0); - gtk_container_add(PGtkContainer(FWidget), FHBox); - g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); - gtk_widget_show(FLabel); - gtk_widget_show(FImage); - gtk_widget_show(FHBox); - Show; -end; - -constructor TGTKImageToggleButton.CreateWithoutLabel(AOwner: TComponent); -begin - inherited Create(AOwner); - FWidget := gtk_button_new; - FLabel := gtk_label_new(''); - FImage := gtk_image_new; - gtk_container_add(PGtkContainer(FWidget), FImage); - g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); - gtk_widget_show(FLabel); - gtk_widget_show(FImage); - Show; -end; - -function TGTKImageToggleButton.GetCaption: string; -begin - Result := gtk_label_get_text(PGtkLabel(FLabel)); -end; - -procedure TGTKImageToggleButton.SetCaption(Value: string); -begin - gtk_label_set_text(PGtkLabel(FLabel), PChar(Value)); -end; - -procedure TGTKImageToggleButton.SetIcon(Value: TGDKPixbuf); -begin - if Assigned(Value) and Assigned(Value.FPixbuf) then - gtk_image_set_from_pixbuf(PGtkImage(FImage), Value.FPixbuf); -end; - -procedure TGTKImageToggleButton.SetFromStock(Stock_ID: string; IconSize: TGTKIconSize); -begin - gtk_image_set_from_stock(PGtkImage(FImage), PChar(Stock_ID), Ord(IconSize)); -end; - -(********************************************************************************************************************************) end. |
