lazarus/components/virtualtreeview/laz.vtideeditors.pas
2019-01-21 14:57:14 +00:00

60 lines
1.1 KiB
ObjectPascal

unit laz.VTIDEEditors;
{$mode objfpc}{$H+}
interface
uses
ComponentEditors, PropEdits, laz.VirtualTrees;
type
// The usual trick to make a protected property accessible in the ShowCollectionEditor call below.
TVirtualTreeCast = class(TBaseVirtualTree);
{ TVirtualTreeEditor }
TVirtualTreeEditor = class(TComponentEditor)
public
procedure Edit; override;
function GetVerbCount: Integer; override;
function GetVerb(Index: Integer): string; override;
procedure ExecuteVerb(Index: Integer); override;
end;
TLazVirtualTreeEditor = class(TVirtualTreeEditor);
implementation
{ TVirtualTreeEditor }
procedure TVirtualTreeEditor.Edit;
var
Tree: TVirtualTreeCast;
begin
Tree := TVirtualTreeCast(GetComponent);
TCollectionPropertyEditor.ShowCollectionEditor(Tree.Header.Columns, Tree, 'Columns');
end;
function TVirtualTreeEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
function TVirtualTreeEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: Result := 'Edit Columns...';
end;
end;
procedure TVirtualTreeEditor.ExecuteVerb(Index: Integer);
begin
case Index of
0: Edit;
end;
end;
end.