mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 17:20:37 +02:00
IDEIntf: TStringGridEditorDlg: notify when columns collection changed
This commit is contained in:
parent
52183ce50b
commit
b87f6260ad
@ -69,6 +69,7 @@ type
|
||||
function IterateTree(ANode: TTreeNode; APers: TPersistent): TTreeNode;
|
||||
procedure NodeCollapsed(Sender: TObject; Node: TTreeNode);
|
||||
procedure NodeExpanded(Sender: TObject; Node: TTreeNode);
|
||||
procedure OnCollectionChanged(Sender: TObject; aColl: TCollection);
|
||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||
procedure OnPersistentDeleted(APersistent: TPersistent);
|
||||
procedure OnPersistentDeleting(APersistent: TPersistent);
|
||||
@ -654,6 +655,7 @@ begin
|
||||
begin
|
||||
FPropertyEditorHook.RemoveHandlerPersistentDeleting(@OnPersistentDeleting);
|
||||
FPropertyEditorHook.RemoveHandlerPersistentDeleted(@OnPersistentDeleted);
|
||||
FPropertyEditorHook.RemoveHandlerCollectionChanged(@OnCollectionChanged);
|
||||
end;
|
||||
|
||||
FPropertyEditorHook:=AValue;
|
||||
@ -661,6 +663,7 @@ begin
|
||||
begin
|
||||
FPropertyEditorHook.AddHandlerPersistentDeleting(@OnPersistentDeleting);
|
||||
FPropertyEditorHook.AddHandlerPersistentDeleted(@OnPersistentDeleted);
|
||||
FPropertyEditorHook.AddHandlerCollectionChanged(@OnCollectionChanged);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -714,6 +717,15 @@ begin
|
||||
DebugLn(['TComponentTreeView.NodeExpanded: Removing node ', TPersistent(Node.Data), ' failed.']);
|
||||
end;
|
||||
|
||||
procedure TComponentTreeView.OnCollectionChanged(Sender: TObject; aColl: TCollection);
|
||||
var
|
||||
Node: TTreeNode;
|
||||
begin
|
||||
Node:=IterateTree(Items.GetFirstNode,aColl);
|
||||
if Node=nil then exit;
|
||||
IdleBuildNodes:=true;
|
||||
end;
|
||||
|
||||
procedure TComponentTreeView.OnIdle(Sender: TObject; var Done: Boolean);
|
||||
begin
|
||||
BuildComponentNodes(true);
|
||||
@ -730,10 +742,8 @@ var
|
||||
begin
|
||||
Node:=IterateTree(Items.GetFirstNode,APersistent);
|
||||
if Node=nil then exit;
|
||||
BeginUpdate;
|
||||
Node.Free;
|
||||
IdleBuildNodes:=true;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
function TComponentTreeView.AddOrGetPersNode(AParentNode: TTreeNode;
|
||||
|
@ -15,7 +15,7 @@ uses
|
||||
// LCL
|
||||
Forms, Controls, Dialogs, StdCtrls, Buttons, Grids, ExtCtrls,
|
||||
// IdeIntf
|
||||
ObjInspStrConsts, IDEWindowIntf;
|
||||
ObjInspStrConsts, IDEWindowIntf, PropEdits;
|
||||
|
||||
type
|
||||
|
||||
@ -95,7 +95,9 @@ procedure TStringGridEditorDlg.AssignGrid(Dest, Src: TStringGrid);
|
||||
var
|
||||
I, J: Integer;
|
||||
col: TGridColumn;
|
||||
aColumnCollectionChanged: Boolean;
|
||||
begin
|
||||
aColumnCollectionChanged:=false;
|
||||
Dest.BeginUpdate;
|
||||
try
|
||||
Dest.Clear;
|
||||
@ -103,16 +105,29 @@ begin
|
||||
|
||||
if Src.Columns.Enabled then
|
||||
begin
|
||||
Dest.Columns.Clear;
|
||||
for I := 0 to Src.Columns.Count-1 do
|
||||
begin
|
||||
col := Dest.Columns.Add;
|
||||
if i=Dest.Columns.Count then
|
||||
begin
|
||||
aColumnCollectionChanged:=true;
|
||||
col := Dest.Columns.Add
|
||||
end
|
||||
else
|
||||
col := Dest.Columns[i];
|
||||
col.Assign(Src.Columns[I]);
|
||||
end;
|
||||
while Dest.Columns.Count>Src.Columns.Count do
|
||||
begin
|
||||
Dest.Columns[Dest.Columns.Count-1].Free;
|
||||
aColumnCollectionChanged:=true;
|
||||
end;
|
||||
Dest.FixedCols := Src.FixedCols;
|
||||
Dest.FixedRows := Src.FixedRows;
|
||||
end else
|
||||
end else if Dest.ColCount <> Src.ColCount then
|
||||
begin
|
||||
aColumnCollectionChanged:=true;
|
||||
Dest.ColCount := Src.ColCount;
|
||||
end;
|
||||
|
||||
for I := 0 to Src.RowCount - 1 do
|
||||
Dest.RowHeights[I] := Src.RowHeights[I];
|
||||
@ -126,6 +141,9 @@ begin
|
||||
finally
|
||||
Dest.EndUpdate;
|
||||
end;
|
||||
|
||||
if aColumnCollectionChanged and (GlobalDesignHook<>nil) then
|
||||
GlobalDesignHook.CallCollectionChangedHandlers(Self,Dest.Columns);
|
||||
end;
|
||||
|
||||
procedure TStringGridEditorDlg.FormCreate(Sender: TObject);
|
||||
|
@ -1396,8 +1396,11 @@ procedure TOICustomPropertyGrid.SetPropertyEditorHook(
|
||||
NewPropertyEditorHook:TPropertyEditorHook);
|
||||
begin
|
||||
if FPropertyEditorHook=NewPropertyEditorHook then exit;
|
||||
if FPropertyEditorHook<>nil then
|
||||
FPropertyEditorHook.RemoveHandlerGetCheckboxForBoolean(@HookGetCheckboxForBoolean);
|
||||
FPropertyEditorHook:=NewPropertyEditorHook;
|
||||
FPropertyEditorHook.AddHandlerGetCheckboxForBoolean(@HookGetCheckboxForBoolean);
|
||||
if FPropertyEditorHook<>nil then
|
||||
FPropertyEditorHook.AddHandlerGetCheckboxForBoolean(@HookGetCheckboxForBoolean);
|
||||
IncreaseChangeStep;
|
||||
SetSelection(FSelection);
|
||||
end;
|
||||
|
@ -1440,6 +1440,7 @@ type
|
||||
) of object;
|
||||
TPropHookPersistentDel = procedure(APersistent: TPersistent) of object;
|
||||
TPropHookDeletePersistent = procedure(var APersistent: TPersistent) of object;
|
||||
TPropHookCollectionChanged = procedure(Sender: TObject; aColl: TCollection) of object;
|
||||
TPropHookGetSelection = procedure(const ASelection: TPersistentSelectionList
|
||||
) of object;
|
||||
TPropHookSetSelection = procedure(const ASelection: TPersistentSelectionList
|
||||
@ -1490,6 +1491,7 @@ type
|
||||
htPersistentDeleting,
|
||||
htPersistentDeleted,
|
||||
htDeletePersistent,
|
||||
htCollectionChanged,
|
||||
htGetSelectedPersistents,
|
||||
htSetSelectedPersistents,
|
||||
// persistent objects
|
||||
@ -1684,6 +1686,12 @@ type
|
||||
const OnDeletePersistent: TPropHookDeletePersistent);
|
||||
procedure RemoveHandlerDeletePersistent(
|
||||
const OnDeletePersistent: TPropHookDeletePersistent);
|
||||
procedure AddHandlerCollectionChanged(
|
||||
const OnCollectionChanged: TPropHookCollectionChanged);
|
||||
procedure RemoveHandlerCollectionChanged(
|
||||
const OnCollectionChanged: TPropHookCollectionChanged);
|
||||
procedure CallCollectionChangedHandlers(Sender: TObject; aCollection: TCollection);
|
||||
|
||||
// persistent selection
|
||||
procedure AddHandlerGetSelection(const OnGetSelection: TPropHookGetSelection);
|
||||
procedure RemoveHandlerGetSelection(const OnGetSelection: TPropHookGetSelection);
|
||||
@ -1713,8 +1721,11 @@ type
|
||||
const OnRefreshPropertyValues: TPropHookRefreshPropertyValues);
|
||||
procedure AddHandlerAddDependency(const OnAddDependency: TPropHookAddDependency);
|
||||
procedure RemoveHandlerAddDependency(const OnAddDependency: TPropHookAddDependency);
|
||||
|
||||
procedure AddHandlerGetCheckboxForBoolean(
|
||||
const OnGetCheckboxForBoolean: TPropHookGetCheckboxForBoolean);
|
||||
procedure RemoveHandlerGetCheckboxForBoolean(
|
||||
const OnGetCheckboxForBoolean: TPropHookGetCheckboxForBoolean);
|
||||
end;
|
||||
|
||||
//==============================================================================
|
||||
@ -7966,6 +7977,28 @@ begin
|
||||
RemoveHandler(htDeletePersistent,TMethod(OnDeletePersistent));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerCollectionChanged(
|
||||
const OnCollectionChanged: TPropHookCollectionChanged);
|
||||
begin
|
||||
AddHandler(htCollectionChanged,TMethod(OnCollectionChanged));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerCollectionChanged(
|
||||
const OnCollectionChanged: TPropHookCollectionChanged);
|
||||
begin
|
||||
RemoveHandler(htCollectionChanged,TMethod(OnCollectionChanged));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.CallCollectionChangedHandlers(Sender: TObject;
|
||||
aCollection: TCollection);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:=FHandlers[htCollectionChanged].Count;
|
||||
while FHandlers[htCollectionChanged].NextDownIndex(i) do
|
||||
TPropHookCollectionChanged(FHandlers[htCollectionChanged][i])(Sender,aCollection);
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerGetSelection(
|
||||
const OnGetSelection: TPropHookGetSelection);
|
||||
begin
|
||||
@ -8123,6 +8156,12 @@ begin
|
||||
AddHandler(htGetCheckboxForBoolean,TMethod(OnGetCheckboxForBoolean));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerGetCheckboxForBoolean(
|
||||
const OnGetCheckboxForBoolean: TPropHookGetCheckboxForBoolean);
|
||||
begin
|
||||
RemoveHandler(htGetCheckboxForBoolean,TMethod(OnGetCheckboxForBoolean));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.SetLookupRoot(APersistent: TPersistent);
|
||||
var
|
||||
i: Integer;
|
||||
|
Loading…
Reference in New Issue
Block a user