From 1b2b4bb4f3ecc034a6e9364d8768e50b167a9680 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 24 Dec 2024 12:41:48 +0100 Subject: Rough GTK3 port --- UColumns.pas | 63 +++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 24 deletions(-) (limited to 'UColumns.pas') diff --git a/UColumns.pas b/UColumns.pas index 773b399..aad8066 100644 --- a/UColumns.pas +++ b/UColumns.pas @@ -22,8 +22,7 @@ unit UColumns; interface uses - gdk2, gtk2, SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKView, GTKPixbuf, - UCoreClasses; + SysUtils, Classes, lazglib2, lazgdk3, lazgtk3, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKView, GTKPixbuf; type TFColumns = class(TGTKDialog) @@ -34,8 +33,8 @@ type TitleHBox: TGTKHBox; ListView: TGTKListView; ListViewScrolledWindow: TGTKScrolledWindow; - ListViewTable: TGTKTable; - MoveUpButton, MoveDownButton: TGTKImageButton; + ListViewGrid: TGTKGrid; + MoveUpButton, MoveDownButton: TGTKButton; procedure FormCreate(Sender: TObject); override; procedure ListViewSelectionChanged(Sender: TObject); procedure MoveUpDownButtonButtonClick(Sender: TObject); @@ -57,27 +56,29 @@ uses ULocale, UConfig; procedure TFColumns.FormCreate(Sender: TObject); var Column: TGTKTreeViewColumn; row_targets: TGtkTargetEntry; + VBox: TGTKVBox; begin row_targets.target := PChar('GTK_TREE_MODEL_ROW'); - row_targets.flags := GTK_TARGET_SAME_WIDGET; + row_targets.flags := guint(GTK_TARGET_SAME_WIDGET); row_targets.info := 1; SetDefaultSize(250, 350); Caption := LANGColumns_Caption; Buttons := [mbOK, mbCancel]; - ShowSeparator := False; TitleEventBox := TGTKEventBox.Create(Self); TitleLabel := TGTKLabel.Create(Self); TitleLabel.Caption := Format('%s', [LANGColumns_Title]); TitleLabel.UseMarkup := True; TitleLabel.XAlign := 0; - TitleLabel.XPadding := 0; - TitleLabel.YPadding := 3; + TitleLabel.MarginStart := 0; + TitleLabel.MarginEnd := 0; + TitleLabel.MarginTop := 3; + TitleLabel.MarginBottom := 3; TitleEventBox.ControlState := csPrelight; TitleFrame := TGTKFrame.CreateWithoutLabel(Self); TitleFrame.ShadowType := stShadowOut; TitleIcon := TGTKImage.Create(Self); - TitleIcon.SetFromStock('gtk-justify-center', isLargeToolbar); + TitleIcon.SetFromIconName('gtk-justify-center', isLargeToolbar); TitleHBox := TGTKHBox.Create(Self); TitleHBox.Homogeneous := False; TitleHBox.AddControlEx(TGTKEventBox.Create(Self), False, False, 5); @@ -87,16 +88,16 @@ begin TitleFrame.AddControl(TitleEventBox); ClientArea.AddControlEx(TitleFrame, False, True, 0); - ListViewTable := TGTKTable.Create(Self); - ListViewTable.BorderWidth := 7; - ClientArea.AddControlEx(ListViewTable, True, True, 0); + ListViewGrid := TGTKGrid.Create(Self); + ListViewGrid.BorderWidth := 7; + ClientArea.AddControlEx(ListViewGrid, True, True, 0); ListView := TGTKListView.CreateTyped(Self, False, [lcBoolean, lcText, lcNumber]); { ListView.Reorderable := True; g_object_set(ListView.FWidget, 'reorderable', integer(True), nil); } - gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(ListView.FWidget), GDK_BUTTON1_MASK, @row_targets, 1, GDK_ACTION_MOVE); - gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(ListView.FWidget), @row_targets, 1, GDK_ACTION_MOVE); + gtk_tree_view_enable_model_drag_source(PGtkTreeView(ListView.FWidget), [GDK_BUTTON1_MASK], @row_targets, 1, [GDK_ACTION_MOVE]); + gtk_tree_view_enable_model_drag_dest(PGtkTreeView(ListView.FWidget), @row_targets, 1, [GDK_ACTION_MOVE]); ListView.RulesHint := True; ListView.ShowHeaders := False; @@ -115,21 +116,35 @@ begin ListViewScrolledWindow.HorizScrollBarPolicy := sbAutomatic; ListViewScrolledWindow.VertScrollBarPolicy := sbAutomatic; ListViewScrolledWindow.ShadowType := stShadowIn; + ListViewScrolledWindow.MarginTop := 5; + ListViewScrolledWindow.MarginBottom := 5; - MoveUpButton := TGTKImageButton.CreateWithoutLabel(Self); - MoveUpButton.SetFromStock('gtk-go-up', isSmallToolbar); + MoveUpButton := TGTKButton.CreateFromIconName(Self, 'gtk-go-up'); MoveUpButton.Tooltip := LANGColumns_MoveUpButtonTooltip; MoveUpButton.CanFocus := False; - MoveDownButton := TGTKImageButton.CreateWithoutLabel(Self); - MoveDownButton.SetFromStock('gtk-go-down', isSmallToolbar); + MoveUpButton.MarginStart := 5; + MoveUpButton.MarginEnd := 5; + MoveUpButton.MarginTop := 5; + MoveUpButton.MarginBottom := 5; + MoveDownButton := TGTKButton.CreateFromIconName(Self, 'gtk-go-down'); MoveDownButton.Tooltip := LANGColumns_MoveDownButtonTooltip; MoveDownButton.CanFocus := False; - - ListViewTable.AddControlEx(0, 1, 3, 4, ListViewScrolledWindow, [taoExpand, taoFill], [taoExpand, taoFill], 0, 5); - ListViewTable.AddControlEx(3, 2, 1, 1, MoveUpButton, [taoShrink, taoFill], [taoShrink], 5, 5); - ListViewTable.AddControlEx(3, 3, 1, 1, MoveDownButton, [taoShrink, taoFill], [taoShrink], 5, 5); - ListViewTable.AddControlEx(3, 1, 1, 1, TGTKLabel.Create(Self), [taoShrink, taoFill], [taoExpand, taoFill], 0, 2); - ListViewTable.AddControlEx(3, 4, 1, 1, TGTKLabel.Create(Self), [taoShrink, taoFill], [taoExpand, taoFill], 0, 2); + MoveDownButton.MarginStart := 5; + MoveDownButton.MarginEnd := 5; + MoveDownButton.MarginTop := 5; + MoveDownButton.MarginBottom := 5; + + ListViewGrid.AddControl(0, 1, 3, 4, ListViewScrolledWindow); + ListViewGrid.AddControl(3, 2, 1, 1, MoveUpButton); + ListViewGrid.AddControl(3, 3, 1, 1, MoveDownButton); + VBox := TGTKVBox.Create(Self); + VBox.MarginTop := 2; + VBox.MarginBottom := 2; + ListViewGrid.AddControl(3, 1, 1, 1, VBox); + VBox := TGTKVBox.Create(Self); + VBox.MarginTop := 2; + VBox.MarginBottom := 2; + ListViewGrid.AddControl(3, 4, 1, 1, VBox); AddColumnItems; -- cgit v1.2.3