implemented TPropertyEditorHook.PersistentDeleting

git-svn-id: trunk@7605 -
This commit is contained in:
mattias 2005-08-30 22:14:55 +00:00
parent b2fac2d231
commit 8bcd2298e6

View File

@ -356,6 +356,7 @@ type
procedure OnPropHookComponentRenamed(AComponent: TComponent); procedure OnPropHookComponentRenamed(AComponent: TComponent);
procedure OnPropHookPersistentAdded(APersistent: TPersistent; procedure OnPropHookPersistentAdded(APersistent: TPersistent;
Select: boolean); Select: boolean);
procedure OnPropHookPersistentDeleting(APersistent: TPersistent);
procedure OnPropHookDeletePersistent(var APersistent: TPersistent); procedure OnPropHookDeletePersistent(var APersistent: TPersistent);
// designer events // designer events
@ -373,8 +374,6 @@ type
AComponentClass: TRegisteredComponent); AComponentClass: TRegisteredComponent);
procedure OnDesignerPersistentDeleted(Sender: TObject; procedure OnDesignerPersistentDeleted(Sender: TObject;
APersistent: TPersistent); APersistent: TPersistent);
procedure OnDesignerRemovePersistent(Sender: TObject;
APersistent: TPersistent);
procedure OnDesignerModified(Sender: TObject); procedure OnDesignerModified(Sender: TObject);
procedure OnDesignerActivated(Sender: TObject); procedure OnDesignerActivated(Sender: TObject);
procedure OnDesignerCloseQuery(Sender: TObject); procedure OnDesignerCloseQuery(Sender: TObject);
@ -1393,6 +1392,7 @@ begin
GlobalDesignHook.AddHandlerBeforeAddPersistent(@OnPropHookBeforeAddPersistent); GlobalDesignHook.AddHandlerBeforeAddPersistent(@OnPropHookBeforeAddPersistent);
GlobalDesignHook.AddHandlerComponentRenamed(@OnPropHookComponentRenamed); GlobalDesignHook.AddHandlerComponentRenamed(@OnPropHookComponentRenamed);
GlobalDesignHook.AddHandlerPersistentAdded(@OnPropHookPersistentAdded); GlobalDesignHook.AddHandlerPersistentAdded(@OnPropHookPersistentAdded);
GlobalDesignHook.AddHandlerPersistentDeleting(@OnPropHookPersistentDeleting);
GlobalDesignHook.AddHandlerDeletePersistent(@OnPropHookDeletePersistent); GlobalDesignHook.AddHandlerDeletePersistent(@OnPropHookDeletePersistent);
ObjectInspector1.PropertyEditorHook:=GlobalDesignHook; ObjectInspector1.PropertyEditorHook:=GlobalDesignHook;
@ -2519,7 +2519,6 @@ Begin
OnPasteComponent:=@OnDesignerPasteComponent; OnPasteComponent:=@OnDesignerPasteComponent;
OnProcessCommand:=@OnProcessIDECommand; OnProcessCommand:=@OnProcessIDECommand;
OnPropertiesChanged:=@OnDesignerPropertiesChanged; OnPropertiesChanged:=@OnDesignerPropertiesChanged;
OnRemovePersistent:=@OnDesignerRemovePersistent;
OnRenameComponent:=@OnDesignerRenameComponent; OnRenameComponent:=@OnDesignerRenameComponent;
OnSetDesigning:=@OnDesignerSetDesigning; OnSetDesigning:=@OnDesignerSetDesigning;
OnShowOptions:=@OnDesignerShowOptions; OnShowOptions:=@OnDesignerShowOptions;
@ -9446,8 +9445,7 @@ begin
ObjectInspector1.FillPersistentComboBox; ObjectInspector1.FillPersistentComboBox;
end; end;
procedure TMainIDE.OnDesignerRemovePersistent(Sender: TObject; procedure TMainIDE.OnPropHookPersistentDeleting(APersistent: TPersistent);
APersistent: TPersistent);
var var
ActiveForm: TCustomForm; ActiveForm: TCustomForm;
ActiveUnitInfo: TUnitInfo; ActiveUnitInfo: TUnitInfo;
@ -9455,18 +9453,22 @@ var
OwnerClassName: string; OwnerClassName: string;
CurDesigner: TDesigner; CurDesigner: TDesigner;
begin begin
CurDesigner:=TDesigner(Sender); if not (APersistent is TComponent) then exit;
CurDesigner:=TDesigner(FindRootDesigner(TComponent(APersistent)));
if CurDesigner=nil then exit;
if dfDestroyingForm in CurDesigner.Flags then exit; if dfDestroyingForm in CurDesigner.Flags then exit;
if not BeginCodeTool(CurDesigner,ActiveSrcEdit,ActiveUnitInfo, if not BeginCodeTool(CurDesigner,ActiveSrcEdit,ActiveUnitInfo,
[ctfSwitchToFormSource]) then exit; [ctfSwitchToFormSource]) then exit;
ActiveForm:=CurDesigner.Form; ActiveForm:=CurDesigner.Form;
if ActiveForm=nil then if ActiveForm=nil then
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form'); RaiseException('[TMainIDE.OnPropHookPersistentDeleting] Error: TDesigner without a form');
// find source for form // find source for form
ActiveUnitInfo:=Project1.UnitWithComponent(CurDesigner.LookupRoot); ActiveUnitInfo:=Project1.UnitWithComponent(CurDesigner.LookupRoot);
if ActiveUnitInfo=nil then begin if ActiveUnitInfo=nil then begin
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: form without source'); RaiseException('[TMainIDE.OnPropHookPersistentDeleting] Error: form without source');
end; end;
if APersistent is TComponent then begin if APersistent is TComponent then begin
// remove component definition from owner source // remove component definition from owner source