From 348cd5c2982aff022ce328f13ffd1d6ffc2e5e97 Mon Sep 17 00:00:00 2001 From: marc Date: Sun, 4 Jan 2004 03:53:36 +0000 Subject: [PATCH] * Changed TComponentSelectionList to TPersistentSelectionList + Added SSHdebugger property git-svn-id: trunk@5007 - --- debugger/debugger.pp | 81 +++-- debugger/sshgdbmidebugger.pas | 61 +++- designer/controlselection.pp | 15 +- designer/designermenu.pp | 34 ++- ide/customformeditor.pp | 68 +++-- ide/debugoptionsfrm.pas | 60 +--- ide/lazarus.pp | 6 +- ide/lazarusidestrconsts.pas | 1 + ide/main.pp | 17 +- ideintf/componenteditors.pas | 11 +- ideintf/componenttreeview.pas | 28 +- ideintf/objectinspector.pp | 106 ++++--- ideintf/objinspstrconsts.pas | 2 +- ideintf/propedits.pp | 539 ++++++++++++++++++---------------- 14 files changed, 563 insertions(+), 466 deletions(-) diff --git a/debugger/debugger.pp b/debugger/debugger.pp index 72086f675a..2edea227b4 100644 --- a/debugger/debugger.pp +++ b/debugger/debugger.pp @@ -856,13 +856,6 @@ type procedure SetState(const AValue: TDBGState); procedure InitTargetStart; virtual; public - constructor Create(const AExternalDebugger: String); virtual; {Virtual constructor makes no sense} - //MWE: there will be a day that they do make sense :-) - // MG: there will be a day that they do make troubles :) - //MWE: do they ? - //MWE: Now they do make sense ! - destructor Destroy; override; - class function Caption: String; virtual; // The name of the debugger as shown in the debuggeroptions class function ExePaths: String; virtual; // The default locations of the exe @@ -870,7 +863,15 @@ type class function CreateProperties: TDebuggerProperties; virtual; // Creates and initializes debuggerproperties class function GetProperties: TDebuggerProperties; // Get the current properties class procedure SetProperties(const AProperties: TDebuggerProperties); // Set the current properties - + + public + constructor Create(const AExternalDebugger: String); virtual; {Virtual constructor makes no sense} + //MWE: there will be a day that they do make sense :-) + // MG: there will be a day that they do make troubles :) + //MWE: do they ? + //MWE: Now they do make sense ! + destructor Destroy; override; + procedure Init; virtual; // Initializes the debugger procedure Done; virtual; // Kills the debugger procedure Run; // Starts / continues debugging @@ -968,7 +969,7 @@ const ); var - MDebuggerProperties: TDebuggerProperties; + MDebuggerPropertiesList: TStringlist; function DBGCommandNameToCommand(const s: string): TDBGCommand; begin @@ -1099,10 +1100,14 @@ begin end; class function TDebugger.CreateProperties: TDebuggerProperties; +var + idx: Integer; begin Result := TDebuggerProperties.Create; - if MDebuggerProperties <> nil - then Result.Assign(MDebuggerProperties); + if MDebuggerPropertiesList = nil then Exit; + idx := MDebuggerPropertiesList.IndexOf(ClassName); + if idx = -1 then Exit; + Result.Assign(TDebuggerProperties(MDebuggerPropertiesList.Objects[idx])); end; function TDebugger.CreateSignals: TDBGSignals; @@ -1234,10 +1239,20 @@ begin end; class function TDebugger.GetProperties: TDebuggerProperties; +var + idx: Integer; begin - if MDebuggerProperties = nil - then MDebuggerProperties := CreateProperties; - Result := MDebuggerProperties; + if MDebuggerPropertiesList = nil + then MDebuggerPropertiesList := TStringList.Create; + idx := MDebuggerPropertiesList.IndexOf(ClassName); + if idx = -1 + then begin + Result := CreateProperties; + MDebuggerPropertiesList.AddObject(ClassName, Result) + end + else begin + Result := TDebuggerProperties(MDebuggerPropertiesList.Objects[idx]); + end; end; function TDebugger.GetState: TDBGState; @@ -1340,15 +1355,15 @@ begin end; class procedure TDebugger.SetProperties(const AProperties: TDebuggerProperties); +var + Props: TDebuggerProperties; begin - if (AProperties=nil) or (AProperties=MDebuggerProperties) then exit; - if MDebuggerProperties = nil - then begin - GetProperties; - if MDebuggerProperties = nil // they weren't created ? - then Exit; - end; - MDebuggerProperties.Assign(AProperties); + if AProperties = nil then Exit; + Props := GetProperties; + if Props = AProperties then Exit; + + if Props = nil then Exit; // they weren't created ? + Props.Assign(AProperties); end; procedure TDebugger.SetState(const AValue: TDBGState); @@ -3132,16 +3147,32 @@ begin inherited SetItem(Aindex, AValue); end; +procedure DoFinalization; +var + n: Integer; +begin + if MDebuggerPropertiesList <> nil + then begin + for n := 0 to MDebuggerPropertiesList.Count - 1 do + MDebuggerPropertiesList.Objects[n].Free; + FreeAndNil(MDebuggerPropertiesList); + end; +end; + initialization - MDebuggerProperties := nil; + MDebuggerPropertiesList := nil; finalization - MDebuggerProperties.Free; - MDebuggerProperties:=nil; + DoFinalization; + end. { ============================================================================= $Log$ + Revision 1.56 2004/01/04 03:53:36 marc + * Changed TComponentSelectionList to TPersistentSelectionList + + Added SSHdebugger property + Revision 1.55 2004/01/03 01:17:25 marc + Added debugger optioes diff --git a/debugger/sshgdbmidebugger.pas b/debugger/sshgdbmidebugger.pas index 1b46deba80..1ba5447c51 100644 --- a/debugger/sshgdbmidebugger.pas +++ b/debugger/sshgdbmidebugger.pas @@ -38,7 +38,7 @@ interface uses Classes, SysUtils, Dialogs, Controls, LazConf, GDBMIDebugger, DBGUtils, - BaseDebugManager; + BaseDebugManager, Debugger, PropEdits, Graphics; type TSSHGDBMIDebugger = class(TGDBMIDebugger) @@ -46,6 +46,7 @@ type protected function ParseInitialization: Boolean; override; public + class function CreateProperties: TDebuggerProperties; override; // Creates and initializes debuggerproperties class function Caption: String; override; class function ExePaths: String; override; end; @@ -53,6 +54,51 @@ type implementation +type + TSSHGDBMIDebuggerProperties = class(TDebuggerProperties) + private + FNote: String; //dummy + published + property Note: String read FNote write FNote; + end; + + TSSHGDBMINotePropertyEditor = class(TStringPropertyEditor) + private + protected + public + function GetAttributes: TPropertyAttributes; override; + function GetValue: ansistring; override; + procedure SetValue(const NewValue: ansistring); override; + procedure PropMeasureHeight(const NewValue: ansistring; ACanvas:TCanvas; + var AHeight:Integer); override; + end; + +{ TSSHGDBMINotePropertyEditor } + +function TSSHGDBMINotePropertyEditor.GetAttributes: TPropertyAttributes; +begin + Result := [paReadOnly]; +end; + +function TSSHGDBMINotePropertyEditor.GetValue: ansistring; +begin + Result := 'The GNU debugger through ssh allows to remote debug via a ssh' + + ' connection. See docs/RemoteDebugging.txt for details. The path' + + ' must contain the ssh client filename, the hostname with an optional' + + ' username and the filename of gdb on the remote computer.' + + ' For example: "/usr/bin/ssh username@hostname gdb"'; +end; + +procedure TSSHGDBMINotePropertyEditor.PropMeasureHeight(const NewValue: ansistring; ACanvas: TCanvas; var AHeight: Integer); +begin + AHeight := 100; +end; + +procedure TSSHGDBMINotePropertyEditor.SetValue (const NewValue: ansistring); +begin + // cannot write to note +end; + { TSSHGDBMIDebugger } @@ -61,6 +107,11 @@ begin Result := 'GNU debugger through SSH (gdb)'; end; +function TSSHGDBMIDebugger.CreateProperties: TDebuggerProperties; +begin + Result := TSSHGDBMIDebuggerProperties.Create; +end; + function TSSHGDBMIDebugger.ExePaths: String; begin Result := '/usr/bin/ssh user@remote /usr/bin/gdb'; @@ -147,12 +198,18 @@ begin end; initialization - RegisterDebugger(TSSHGDBMIDebugger); + RegisterPropertyEditor(TypeInfo(String), TSSHGDBMIDebuggerProperties, 'Note', TSSHGDBMINotePropertyEditor); + RegisterDebugger(TSSHGDBMIDebugger); + end. { ============================================================================= $Log$ + Revision 1.7 2004/01/04 03:53:36 marc + * Changed TComponentSelectionList to TPersistentSelectionList + + Added SSHdebugger property + Revision 1.6 2003/12/27 11:22:37 mattias minor fixes diff --git a/designer/controlselection.pp b/designer/controlselection.pp index be0885b838..9eddecd028 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -353,7 +353,7 @@ type procedure Clear; function AssignComponent(AComponent:TComponent): boolean; procedure Assign(AControlSelection: TControlSelection); - procedure AssignSelection(ASelection: TComponentSelectionList); + procedure AssignSelection(const ASelection: TPersistentSelectionList); function IsSelected(AComponent: TComponent): Boolean; function IsOnlySelected(AComponent: TComponent): Boolean; procedure SaveBounds; @@ -1823,9 +1823,11 @@ begin DoChange; end; -procedure TControlSelection.AssignSelection(ASelection: TComponentSelectionList - ); -var i:integer; +procedure TControlSelection.AssignSelection( + const ASelection: TPersistentSelectionList); +var + i:integer; + instance: TPersistent; begin if (cssNotSavingBounds in FStates) then exit; Include(FStates,cssNotSavingBounds); @@ -1833,7 +1835,10 @@ begin Clear; FControls.Capacity:=ASelection.Count; for i:=0 to ASelection.Count-1 do - Add(ASelection[i]); + begin + Instance := ASelection[i]; + if Instance is TComponent then Add(TComponent(Instance)); + end; SetCustomForm; UpdateBounds; Exclude(FStates,cssNotSavingBounds); diff --git a/designer/designermenu.pp b/designer/designermenu.pp index 99a0bc0eee..3e387d4f8f 100644 --- a/designer/designermenu.pp +++ b/designer/designermenu.pp @@ -1252,34 +1252,36 @@ end; // --------------------------------------------------------------------------------------------------------------// procedure TDesignerMainMenu.OnComponentModified(Sender: TComponent); var - SelectedComponents: TComponentSelectionList; + Selection: TPersistentSelectionList; i: Integer; - AComponent: TComponent; - AMenuItem: TMenuItem; + Instance: TPersistent; + MenuItem: TMenuItem; InvalidateNeeded: Boolean; - ADesignerMenuItem: PDesignerMenuItem; + DesignerMenuItem: PDesignerMenuItem; begin - SelectedComponents:=TComponentSelectionList.Create; - GlobalDesignHook.GetSelectedComponents(SelectedComponents); + Selection := TPersistentSelectionList.Create; + GlobalDesignHook.GetSelection(Selection); try InvalidateNeeded:=false; - for i:=SelectedComponents.Count-1 downto 0 do begin - AComponent:=SelectedComponents[i]; - if AComponent is TMenuItem then begin - AMenuItem:=TMenuItem(AComponent); + for i := Selection.Count - 1 downto 0 do + begin + Instance := Selection[i]; + if Instance is TMenuItem + then begin + MenuItem:=TMenuItem(Instance); // ToDo // how to get the Designer menu item? - ADesignerMenuItem:=GetDesignerMenuItem(Root, AMenuItem.Name); - if ADesignerMenuItem<>nil then begin - ChangeCaption(ADesignerMenuItem,AMenuItem.Caption); - InvalidateNeeded:=true; - end; + DesignerMenuItem:=GetDesignerMenuItem(Root, MenuItem.Name); + if DesignerMenuItem = nil then Continue; + + ChangeCaption(DesignerMenuItem, MenuItem. Caption); + InvalidateNeeded := true; end; end; if InvalidateNeeded then Parent.Invalidate; finally - SelectedComponents.Free; + Selection.Free; end; end; diff --git a/ide/customformeditor.pp b/ide/customformeditor.pp index 6368e92393..163de12611 100644 --- a/ide/customformeditor.pp +++ b/ide/customformeditor.pp @@ -117,12 +117,12 @@ each control that's dropped onto the form private FComponentInterfaces: TAVLTree; // tree of TComponentInterface sorted for // component - FSelectedComponents: TComponentSelectionList; + FSelection: TPersistentSelectionList; FObj_Inspector: TObjectInspector; function GetPropertyEditorHook: TPropertyEditorHook; protected FNonControlForms: TAVLTree; // tree of TNonControlForm sorted for LookupRoot - procedure SetSelectedComponents(TheSelectedComponents : TComponentSelectionList); + procedure SetSelection(const ASelection: TPersistentSelectionList); procedure OnObjectInspectorModified(Sender: TObject); procedure SetObj_Inspector(AnObjectInspector: TObjectInspector); virtual; procedure JITListReaderError(Sender: TObject; ErrorType: TJITFormError; @@ -177,8 +177,8 @@ each control that's dropped onto the form function TranslateKeyToDesignerCommand(Key: word; Shift: TShiftState): word; public - property SelectedComponents: TComponentSelectionList - read FSelectedComponents write SetSelectedComponents; + property Selection: TPersistentSelectionList read FSelection + write SetSelection; property Obj_Inspector: TObjectInspector read FObj_Inspector write SetObj_Inspector; property PropertyEditorHook: TPropertyEditorHook read GetPropertyEditorHook; @@ -647,7 +647,7 @@ begin inherited Create; FComponentInterfaces := TAVLTree.Create(@CompareComponentInterfaces); FNonControlForms:=TAVLTree.Create(@CompareNonControlForms); - FSelectedComponents := TComponentSelectionList.Create; + FSelection := TPersistentSelectionList.Create; JITFormList := TJITForms.Create; JITFormList.OnReaderError:=@JITListReaderError; @@ -662,30 +662,29 @@ end; destructor TCustomFormEditor.Destroy; begin DesignerMenuItemClick:=nil; - JITFormList.Free; - JITDataModuleList.Free; - FComponentInterfaces.Free; - FSelectedComponents.Free; - FNonControlForms.Free; + FreeAndNil(JITFormList); + FreeAndNil(JITDataModuleList); + FreeAndNil(FComponentInterfaces); + FreeAndNil(FSelection); + FreeAndNil(FNonControlForms); inherited Destroy; end; -procedure TCustomFormEditor.SetSelectedComponents( - TheSelectedComponents: TComponentSelectionList); +procedure TCustomFormEditor.SetSelection( + const ASelection: TPersistentSelectionList); begin - FSelectedComponents.Assign(TheSelectedComponents); - if FSelectedComponents.Count>0 then begin + FSelection.Assign(ASelection); + if FSelection.Count>0 then begin Obj_Inspector.PropertyEditorHook.LookupRoot:= - GetLookupRootForComponent(FSelectedComponents[0]); + GetLookupRootForComponent(FSelection[0]); end; - Obj_Inspector.Selections := FSelectedComponents; + Obj_Inspector.Selection := FSelection; end; Function TCustomFormEditor.AddSelected(Value : TComponent) : Integer; Begin - FSelectedComponents.Add(Value); - Result := FSelectedComponents.Count; - Obj_Inspector.Selections := FSelectedComponents; + Result := FSelection.Add(Value) + 1; + Obj_Inspector.Selection := FSelection; end; Procedure TCustomFormEditor.DeleteControl(AComponent: TComponent; @@ -1203,7 +1202,7 @@ end; Procedure TCustomFormEditor.ClearSelected; Begin - FSelectedComponents.Clear; + FSelection.Clear; end; function TCustomFormEditor.TranslateKeyToDesignerCommand(Key: word; @@ -1231,19 +1230,24 @@ begin end; procedure TCustomFormEditor.OnObjectInspectorModified(Sender: TObject); -var CustomForm: TCustomForm; +var + CustomForm: TCustomForm; + Instance: TPersistent; begin - if (FSelectedComponents<>nil) and (FSelectedComponents.Count>0) then begin - if FSelectedComponents[0] is TCustomForm then - CustomForm:=TCustomForm(FSelectedComponents[0]) - else if (FSelectedComponents[0].Owner<>nil) - and (FSelectedComponents[0].Owner is TCustomForm) then - CustomForm:=TCustomForm(FSelectedComponents[0].Owner) - else - CustomForm:=nil; - if (CustomForm<>nil) and (CustomForm.Designer<>nil) then - CustomForm.Designer.Modified; - end; + if (FSelection = nil) + or (FSelection.Count <= 0) then Exit; + + Instance := FSelection[0]; + if Instance is TCustomForm + then CustomForm:=TCustomForm(Instance) + else if (Instance is TComponent) + and (TComponent(Instance).Owner <> nil) + and (TComponent(Instance).Owner is TCustomForm) + then CustomForm:=TCustomForm(TComponent(Instance).Owner) + else CustomForm:=nil; + + if (CustomForm<>nil) and (CustomForm.Designer<>nil) then + CustomForm.Designer.Modified; end; procedure TCustomFormEditor.SetObj_Inspector( diff --git a/ide/debugoptionsfrm.pas b/ide/debugoptionsfrm.pas index d78be26d6b..495f757a9d 100644 --- a/ide/debugoptionsfrm.pas +++ b/ide/debugoptionsfrm.pas @@ -94,9 +94,7 @@ type FPropertyEditorHook: TPropertyEditorHook; FExceptionDeleteList: TStringList; FOldDebuggerPathAndParams: string; - FDebuggerSpecificComponents: TList; FCurDebuggerClass: TDebuggerClass; // currently shown debugger class - FCurDebuggerObject: TDebugger; // currently shown debugger object procedure AddExceptionLine(const AException: TIDEException; AName: String); procedure AddSignalLine(const ASignal: TIDESignal); procedure FetchDebuggerClass; @@ -191,52 +189,16 @@ end; procedure TDebuggerOptionsForm.FetchDebuggerSpecificOptions; var i: Integer; - AMemo: TMemo; - //Selection: TComponentSelectionList; begin - -// FPropertyEditorHook.LookupRoot := nil; - {ThePropertyEditorHook.LookupRoot:=FCurDebuggerObject; - Selection:=TComponentSelectionList.Create; - if FCurDebuggerObject<>nil then - Selection.Add(AComponent); - PropertyGrid.Selections:=Selection; - Selection.Free;} - - // clear debugger specific options components - if FDebuggerSpecificComponents=nil then - FDebuggerSpecificComponents:=TList.Create; - for i:=0 to FDebuggerSpecificComponents.Count-1 do - TComponent(FDebuggerSpecificComponents[i]).Free; - FDebuggerSpecificComponents.Clear; +// FPropertyEditorHook.LookupRoot := FCurDebuggerClass.GetProperties; + PropertyGrid.Clear; + PropertyGrid.Selection.Clear; if FCurDebuggerClass = nil then Exit; -// FPropertyEditorHook.LookupRoot := FCurDebuggerClass.GetProperties; - PropertyGrid.Clear; -// PropertyGrid.Selections.Add(FCurDebuggerClass.GetProperties); + // todo: use create properties to allow cancel + PropertyGrid.Selection.Add(FCurDebuggerClass.GetProperties); PropertyGrid.BuildPropertyList; - - // create debugger specific options components - // temp hack - if AnsiCompareText(FCurDebuggerClass.ClassName, 'TSSHGDBMIDEBUGGER')=0 - then begin - AMemo:=TMemo.Create(Self); - FDebuggerSpecificComponents.Add(AMemo); - with AMemo do - begin - Name:='DebOptsSpecMemo1'; - Parent:=gbDebuggerSpecific; - SetBounds(5,5,Parent.Width-15,Parent.Height-40); - WordWrap:=true; - ReadOnly:=true; - Caption:='The GNU debugger through ssh allows to remote debug via a ssh' - +' connection. See docs/RemoteDebugging.txt for details. The path' - +' must contain the ssh client filename, the hostname with an optional' - +' username and the filename of gdb on the remote computer.' - +' For example: "/usr/bin/ssh username@hostname gdb"'; - end; - end; end; function TDebuggerOptionsForm.GetDebuggerClass: TDebuggerClass; @@ -258,14 +220,6 @@ begin if FCurDebuggerClass = AClass then Exit; FCurDebuggerClass := AClass; FetchDebuggerSpecificOptions; - // destroy, replace or destroy Debugger instance - {if (FCurDebuggerObject<>nil) - and ((FCurDebuggerClass=nil) - or (not (FCurDebuggerObject is FCurDebuggerClass))) - then - FreeAndNil(FCurDebuggerObject); - if (FCurDebuggerObject=nil) and (FCurDebuggerClass<>nil) then - FCurDebuggerObject:=FCurDebuggerClass.Create('');} end; procedure TDebuggerOptionsForm.clbExceptionsCLICK (Sender: TObject ); @@ -415,7 +369,6 @@ begin Align:=alClient; SplitterX:=120; end; -// pnlDebugSpecific.Visible := False; FetchDebuggerClass; @@ -425,9 +378,8 @@ end; procedure TDebuggerOptionsForm.DebuggerOptionsFormDESTROY(Sender: TObject); begin - FreeAndNil(FDebuggerSpecificComponents); FreeAndNil(FExceptionDeleteList); - FreeAndNil(FCurDebuggerObject); + FreeAndNil(FPropertyEditorHook); end; diff --git a/ide/lazarus.pp b/ide/lazarus.pp index 56df54f397..57fe8dd60a 100644 --- a/ide/lazarus.pp +++ b/ide/lazarus.pp @@ -34,7 +34,7 @@ program Lazarus; {$mode objfpc}{$H+} -{$I ide.inc} +//{$I ide.inc} {$IFDEF WIN32} {$R *.res} @@ -99,6 +99,10 @@ end. { $Log$ + Revision 1.53 2004/01/04 03:53:35 marc + * Changed TComponentSelectionList to TPersistentSelectionList + + Added SSHdebugger property + Revision 1.52 2003/08/18 14:40:29 mattias deactivated memcheck diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index b9cbea2945..ad037bb46c 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -1197,6 +1197,7 @@ resourcestring srkmecunknown = 'unknown editor command'; //Key strings + //TODO: remove, they are meved to IntfStrConsts srVK_UNKNOWN = 'Unknown'; srVK_LBUTTON = 'Mouse Button Left'; srVK_RBUTTON = 'Mouse Button Right'; diff --git a/ide/main.pp b/ide/main.pp index db9411b84e..5cfd1ae7aa 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -975,7 +975,7 @@ end; procedure TMainIDE.OIOnSelectComponents(Sender: TObject); begin - TheControlSelection.AssignSelection(ObjectInspector1.Selections); + TheControlSelection.AssignSelection(ObjectInspector1.Selection); end; procedure TMainIDE.OIOnShowOptions(Sender: TObject); @@ -8162,18 +8162,19 @@ end; procedure TMainIDE.OnControlSelectionChanged(Sender: TObject); var - NewSelectedComponents : TComponentSelectionList; + NewSelection: TPersistentSelectionList; i: integer; begin {$IFDEF IDE_DEBUG} writeln('[TMainIDE.OnControlSelectionChanged]'); {$ENDIF} if (TheControlSelection=nil) or (FormEditor1=nil) then exit; - NewSelectedComponents:=TComponentSelectionList.Create; + + NewSelection:=TPersistentSelectionList.Create; for i:=0 to TheControlSelection.Count-1 do - NewSelectedComponents.Add(TheControlSelection[i].Component); - FormEditor1.SelectedComponents:=NewSelectedComponents; - NewSelectedComponents.Free; + NewSelection.Add(TheControlSelection[i].Component); + FormEditor1.Selection:=NewSelection; + NewSelection.Free; {$IFDEF IDE_DEBUG} writeln('[TMainIDE.OnControlSelectionChanged] END'); {$ENDIF} @@ -10264,6 +10265,10 @@ end. { ============================================================================= $Log$ + Revision 1.693 2004/01/04 03:53:35 marc + * Changed TComponentSelectionList to TPersistentSelectionList + + Added SSHdebugger property + Revision 1.692 2004/01/04 00:05:51 mattias added double click for menu editor diff --git a/ideintf/componenteditors.pas b/ideintf/componenteditors.pas index 5db663a038..4f1e506867 100644 --- a/ideintf/componenteditors.pas +++ b/ideintf/componenteditors.pas @@ -435,7 +435,6 @@ end; procedure TDefaultComponentEditor.Edit; var - Components: TComponentSelectionList; PropertyEditorHook: TPropertyEditorHook; NewLookupRoot: TPersistent; begin @@ -448,20 +447,18 @@ begin FContinue := True; FFirst := nil; FBest := nil; - Components := TComponentSelectionList.Create; try - Components.Add(Component); - GetComponentProperties(Components, tkAny, PropertyEditorHook, - @CheckEdit, nil); - if FContinue then + GetPersistentProperties(Component, tkAny, PropertyEditorHook, @CheckEdit, nil); + if FContinue + then begin if Assigned(FBest) then FBest.Edit else if Assigned(FFirst) then FFirst.Edit; + end; finally FFirst := nil; FBest := nil; - Components.Free; end; end; diff --git a/ideintf/componenttreeview.pas b/ideintf/componenttreeview.pas index 0b44ed5bb5..5fdae6e714 100644 --- a/ideintf/componenttreeview.pas +++ b/ideintf/componenttreeview.pas @@ -42,9 +42,9 @@ type private FComponentList: TBackupComponentList; FPropertyEditorHook: TPropertyEditorHook; - function GetSelections: TComponentSelectionList; + function GetSelection: TPersistentSelectionList; procedure SetPropertyEditorHook(const AValue: TPropertyEditorHook); - procedure SetSelections(const NewSelections: TComponentSelectionList); + procedure SetSelection(const NewSelection: TPersistentSelectionList); protected procedure DoSelectionChanged; override; public @@ -54,8 +54,8 @@ type procedure UpdateComponentNodesValues; virtual; function CreateNodeCaption(APersistent: TPersistent): string; virtual; public - property Selections: TComponentSelectionList read GetSelections - write SetSelections; + property Selection: TPersistentSelectionList read GetSelection + write SetSelection; property PropertyEditorHook: TPropertyEditorHook read FPropertyEditorHook write SetPropertyEditorHook; property OnSelectionChanged; @@ -65,15 +65,15 @@ implementation { TComponentTreeView } -procedure TComponentTreeView.SetSelections( - const NewSelections: TComponentSelectionList); +procedure TComponentTreeView.SetSelection( + const NewSelection: TPersistentSelectionList); begin if (PropertyEditorHook=nil) then begin if (FComponentList.LookupRoot=nil) then exit; FComponentList.Clear; end else begin - if FComponentList.IsEqual(PropertyEditorHook.LookupRoot,NewSelections) then + if FComponentList.IsEqual(PropertyEditorHook.LookupRoot,NewSelection) then begin // nodes ok, but maybe node values needs update UpdateComponentNodesValues; @@ -81,7 +81,7 @@ begin end; end; FComponentList.LookupRoot:=PropertyEditorHook.LookupRoot; - FComponentList.Selection.Assign(NewSelections); + FComponentList.Selection.Assign(NewSelection); RebuildComponentNodes; end; @@ -89,9 +89,9 @@ procedure TComponentTreeView.DoSelectionChanged; var ANode: TTreeNode; AComponent: TComponent; - NewSelection: TComponentSelectionList; + NewSelection: TPersistentSelectionList; begin - NewSelection:=TComponentSelectionList.Create; + NewSelection:=TPersistentSelectionList.Create; try if (PropertyEditorHook<>nil) and (PropertyEditorHook.LookupRoot<>nil) @@ -124,7 +124,7 @@ begin RebuildComponentNodes; end; -function TComponentTreeView.GetSelections: TComponentSelectionList; +function TComponentTreeView.GetSelection: TPersistentSelectionList; begin Result:=FComponentList.Selection; end; @@ -157,7 +157,7 @@ procedure TComponentTreeView.RebuildComponentNodes; NewNode:=Items.AddChild(ANode,CreateNodeCaption(CurControl)); NewNode.Data:=CurControl; NewNode.ImageIndex:=-1; - NewNode.MultiSelected:=Selections.IndexOf(CurControl)>=0; + NewNode.MultiSelected:=Selection.IndexOf(CurControl)>=0; if CurControl is TWinControl then AddChildControls(TWinControl(CurControl),NewNode); end; @@ -185,7 +185,7 @@ begin RootNode:=Items.Add(nil,CreateNodeCaption(RootObject)); RootNode.Data:=RootObject; RootNode.ImageIndex:=-1; - RootNode.MultiSelected:=Selections.IndexOf(RootObject)>=0; + RootNode.MultiSelected:=Selection.IndexOf(RootObject)>=0; // add components in creation order and TControl.Parent relationship if RootObject is TComponent then begin @@ -201,7 +201,7 @@ begin NewNode:=Items.AddChild(RootNode,CreateNodeCaption(AComponent)); NewNode.Data:=AComponent; NewNode.ImageIndex:=-1; - NewNode.MultiSelected:=Selections.IndexOf(AComponent)>=0; + NewNode.MultiSelected:=Selection.IndexOf(AComponent)>=0; if AComponent is TWinControl then AddChildControls(TWinControl(AComponent),NewNode); end; diff --git a/ideintf/objectinspector.pp b/ideintf/objectinspector.pp index 3f58bb508e..33188c18ef 100644 --- a/ideintf/objectinspector.pp +++ b/ideintf/objectinspector.pp @@ -168,7 +168,7 @@ type TOIPropertyGrid = class(TCustomControl) private FChangeStep: integer; - FComponentList: TComponentSelectionList; + FSelection: TPersistentSelectionList; FPropertyEditorHook: TPropertyEditorHook; FFilter: TTypeKinds; FItemIndex:integer; @@ -216,7 +216,7 @@ type procedure PaintRow(ARow:integer); procedure DoPaint(PaintOnlyChangedValues:boolean); - procedure SetSelections(const NewSelections:TComponentSelectionList); + procedure SetSelection(const ASelection:TPersistentSelectionList); procedure SetPropertyEditorHook(NewPropertyEditorHook:TPropertyEditorHook); procedure AddPropertyEditor(PropEditor: TPropertyEditor); @@ -259,8 +259,8 @@ type ValueComboBox:TComboBox; ValueButton:TButton; - property Selections: TComponentSelectionList read FComponentList - write SetSelections; + property Selection: TPersistentSelectionList read FSelection + write SetSelection; property PropertyEditorHook: TPropertyEditorHook read FPropertyEditorHook write SetPropertyEditorHook; procedure BuildPropertyList; @@ -343,7 +343,7 @@ type procedure OnMainPopupMenuPopup(Sender: TObject); procedure HookRefreshPropertyValues; private - FComponentList: TComponentSelectionList; + FSelection: TPersistentSelectionList; FComponentTreeHeight: integer; FDefaultItemHeight: integer; FFlags: TOIFlags; @@ -361,12 +361,12 @@ type procedure SetDefaultItemHeight(const AValue: integer); procedure SetOnShowOptions(const AValue: TNotifyEvent); procedure SetPropertyEditorHook(NewValue:TPropertyEditorHook); - procedure SetSelections(const NewSelections:TComponentSelectionList); + procedure SetSelection(const ASelection:TPersistentSelectionList); procedure AddComponentToList(AComponent:TComponent; List: TStrings); procedure HookLookupRootChange; procedure OnGridModified(Sender: TObject); procedure SetAvailComboBoxText; - procedure HookGetSelectedComponents(Selection: TComponentSelectionList); + procedure HookGetSelection(const ASelection: TPersistentSelectionList); procedure SetShowComponentTree(const AValue: boolean); procedure SetUsePairSplitter(const AValue: boolean); procedure CreatePairSplitter; @@ -375,7 +375,7 @@ type public constructor Create(AnOwner: TComponent); override; destructor Destroy; override; - procedure RefreshSelections; + procedure RefreshSelection; procedure RefreshPropertyValues; procedure RebuildPropertyLists; procedure FillComponentComboBox; @@ -387,8 +387,8 @@ type public property DefaultItemHeight: integer read FDefaultItemHeight write SetDefaultItemHeight; - property Selections: TComponentSelectionList - read FComponentList write SetSelections; + property Selection: TPersistentSelectionList + read FSelection write SetSelection; property OnAddAvailComponent: TOnAddAvailableComponent read FOnAddAvailableComponent write FOnAddAvailableComponent; property OnSelectComponentsInOI: TNotifyEvent @@ -427,7 +427,7 @@ constructor TOIPropertyGrid.CreateWithParams(AnOwner:TComponent; DefItemHeight: integer); begin inherited Create(AnOwner); - FComponentList:=TComponentSelectionList.Create; + FSelection:=TPersistentSelectionList.Create; FPropertyEditorHook:=APropertyEditorHook; FFilter:=TypeFilter; FItemIndex:=-1; @@ -600,7 +600,7 @@ begin FItemIndex:=-1; for a:=0 to FRows.Count-1 do Rows[a].Free; FreeAndNil(FRows); - FreeAndNil(FComponentList); + FreeAndNil(FSelection); FreeAndNil(FValueFont); FreeAndNil(FNameFont); FreeAndNil(FExpandedProperties); @@ -631,8 +631,8 @@ begin Result:=0; end; -procedure TOIPropertyGrid.SetSelections( - const NewSelections:TComponentSelectionList); +procedure TOIPropertyGrid.SetSelection( + const ASelection: TPersistentSelectionList); var CurRow:TOIPropertyGridRow; OldSelectedRowPath:string; @@ -640,7 +640,7 @@ begin OldSelectedRowPath:=PropertyPath(ItemIndex); ItemIndex:=-1; ClearRows; - FComponentList.Assign(NewSelections); + FSelection.Assign(ASelection); BuildPropertyList; CurRow:=GetRowByPath(OldSelectedRowPath); if CurRow<>nil then @@ -653,7 +653,7 @@ begin if FPropertyEditorHook=NewPropertyEditorHook then exit; FPropertyEditorHook:=NewPropertyEditorHook; IncreaseChangeStep; - SetSelections(FComponentList); + SetSelection(FSelection); end; function TOIPropertyGrid.PropertyPath(Index:integer):string; @@ -980,7 +980,7 @@ begin for a:=0 to FRows.Count-1 do Rows[a].Free; FRows.Clear; // get properties - GetComponentProperties(FComponentList,FFilter,FPropertyEditorHook, + GetPersistentProperties(FSelection, FFilter, FPropertyEditorHook, @AddPropertyEditor,nil); // sort FRows.Sort(@SortGridRows); @@ -2196,7 +2196,7 @@ begin inherited Create(AnOwner); Caption := oisObjectInspector; FPropertyEditorHook:=nil; - FComponentList:=TComponentSelectionList.Create; + FSelection:=TPersistentSelectionList.Create; FUpdatingAvailComboBox:=false; Name := DefaultObjectInspectorName; FDefaultItemHeight := 22; @@ -2282,7 +2282,7 @@ end; destructor TObjectInspector.Destroy; begin - FComponentList.Free; + FreeAndNil(FSelection); inherited Destroy; end; @@ -2297,18 +2297,17 @@ begin FPropertyEditorHook.AddHandlerChangeLookupRoot(@HookLookupRootChange); FPropertyEditorHook.AddHandlerRefreshPropertyValues( @HookRefreshPropertyValues); - FPropertyEditorHook.AddHandlerGetSelectedComponents( - @HookGetSelectedComponents); + FPropertyEditorHook.AddHandlerGetSelection(@HookGetSelection); // select root component - FComponentList.Clear; + FSelection.Clear; if (FPropertyEditorHook<>nil) and (FPropertyEditorHook.LookupRoot<>nil) and (FPropertyEditorHook.LookupRoot is TComponent) then - FComponentList.Add(TComponent(FPropertyEditorHook.LookupRoot)); + FSelection.Add(TComponent(FPropertyEditorHook.LookupRoot)); FillComponentComboBox; PropertyGrid.PropertyEditorHook:=FPropertyEditorHook; EventGrid.PropertyEditorHook:=FPropertyEditorHook; ComponentTree.PropertyEditorHook:=FPropertyEditorHook; - RefreshSelections; + RefreshSelection; end; end; @@ -2379,7 +2378,7 @@ begin if FUpdatingAvailComboBox then exit; FUpdatingAvailComboBox:=true; if ComponentTree<>nil then - ComponentTree.Selections:=FComponentList; + ComponentTree.Selection:=FSelection; NewList:=TStringList.Create; try if (FPropertyEditorHook<>nil) @@ -2467,23 +2466,22 @@ begin end; end; -procedure TObjectInspector.SetSelections( - const NewSelections:TComponentSelectionList); +procedure TObjectInspector.SetSelection( + const ASelection:TPersistentSelectionList); begin -//writeln('[TObjectInspector.SetSelections] ',NewSelections.Count); - if FComponentList.IsEqual(NewSelections) then exit; - FComponentList.Assign(NewSelections); + if FSelection.IsEqual(ASelection) then exit; + FSelection.Assign(ASelection); SetAvailComboBoxText; - RefreshSelections; + RefreshSelection; end; -procedure TObjectInspector.RefreshSelections; +procedure TObjectInspector.RefreshSelection; begin - PropertyGrid.Selections:=FComponentList; - EventGrid.Selections:=FComponentList; - ComponentTree.Selections:=FComponentList; + PropertyGrid.Selection := FSelection; + EventGrid.Selection := FSelection; + ComponentTree.Selection := FSelection; ComponentTree.MakeSelectionVisible; - if (not Visible) and (FComponentList.Count>0) then + if (not Visible) and (FSelection.Count>0) then Visible:=true; end; @@ -2510,10 +2508,10 @@ var NewComponent,Root:TComponent; procedure SetSelectedComponent(c:TComponent); begin - if (FComponentList.Count=1) and (FComponentList[0]=c) then exit; - FComponentList.Clear; - FComponentList.Add(c); - RefreshSelections; + if (FSelection.Count=1) and (FSelection[0]=c) then exit; + FSelection.Clear; + FSelection.Add(c); + RefreshSelection; if Assigned(FOnSelectComponentsInOI) then FOnSelectComponentsInOI(Self); end; @@ -2542,9 +2540,9 @@ end; procedure TObjectInspector.ComponentTreeSelectionChanged(Sender: TObject); begin if (PropertyEditorHook=nil) or (PropertyEditorHook.LookupRoot=nil) then exit; - if FComponentList.IsEqual(ComponentTree.Selections) then exit; - FComponentList.Assign(ComponentTree.Selections); - RefreshSelections; + if FSelection.IsEqual(ComponentTree.Selection) then exit; + Fselection.Assign(ComponentTree.Selection); + RefreshSelection; if Assigned(FOnSelectComponentsInOI) then FOnSelectComponentsInOI(Self); end; @@ -2592,19 +2590,19 @@ end; procedure TObjectInspector.SetAvailComboBoxText; begin - if FComponentList.Count=1 then - AvailCompsComboBox.Text:=ComponentToString(FComponentList[0]) - else if FComponentList.Count>1 then - AvailCompsComboBox.Text:=IntToStr(FComponentList.Count)+oisItemsSelected + case FSelection.Count of + 1: AvailCompsComboBox.Text:=ComponentToString(FSelection[0]); + 0: AvailCompsComboBox.Text:=''; else - AvailCompsComboBox.Text:=''; + AvailCompsComboBox.Text:=Format(oisItemsSelected, [FSelection.Count]); + end; end; -procedure TObjectInspector.HookGetSelectedComponents( - Selection: TComponentSelectionList); +procedure TObjectInspector.HookGetSelection( + const ASelection: TPersistentSelectionList); begin - if Selection=nil then exit; - Selection.Assign(FComponentList); + if ASelection=nil then exit; + ASelection.Assign(FSelection); end; procedure TObjectInspector.SetShowComponentTree(const AValue: boolean); @@ -2717,7 +2715,7 @@ begin ValueEdit.Parent:=Parent; ValueComboBox.Parent:=Parent; ValueButton.Parent:=Parent; - Selections:=Self.FComponentList; + Selection:=Self.FSelection; Align:=alClient; PopupMenu:=MainPopupMenu; OnModified:=@OnGridModified; @@ -2732,7 +2730,7 @@ begin ValueEdit.Parent:=Parent; ValueComboBox.Parent:=Parent; ValueButton.Parent:=Parent; - Selections:=Self.FComponentList; + Selection:=Self.FSelection; Align:=alClient; PopupMenu:=MainPopupMenu; OnModified:=@OnGridModified; diff --git a/ideintf/objinspstrconsts.pas b/ideintf/objinspstrconsts.pas index 4a97b30519..336031f55c 100644 --- a/ideintf/objinspstrconsts.pas +++ b/ideintf/objinspstrconsts.pas @@ -19,7 +19,7 @@ interface resourcestring // oisObjectInspector = 'Object Inspector'; - oisItemsSelected = ' items selected'; + oisItemsSelected = '%u items selected'; oiscAdd = '&Add'; oiscDelete = '&Delete'; diff --git a/ideintf/propedits.pp b/ideintf/propedits.pp index c3a2b1f2c0..93a54e9a56 100644 --- a/ideintf/propedits.pp +++ b/ideintf/propedits.pp @@ -49,7 +49,7 @@ const type TGetStringProc = procedure(const s:ansistring) of object; - TComponentSelectionList = class; + TPersistentSelectionList = class; { TPropertyEditor Edits a property of a component, or list of components, selected into the @@ -274,7 +274,7 @@ type TPropertyEditor=class private - FComponents: TComponentSelectionList; + FComponents: TPersistentSelectionList; FOnSubPropertiesChanged: TNotifyEvent; FPropertyHook: TPropertyEditorHook; FPropCount: Integer; @@ -304,7 +304,7 @@ type procedure Modified; public constructor Create(Hook:TPropertyEditorHook; - ComponentList: TComponentSelectionList; + APersistentList: TPersistentSelectionList; APropCount:Integer); virtual; destructor Destroy; override; procedure Activate; virtual; @@ -527,7 +527,7 @@ type protected function FilterFunc(const ATestEditor: TPropertyEditor{IProperty}): Boolean; function GetComponentReference: TComponent; virtual; - function GetSelections: TComponentSelectionList{IDesignerSelections}; virtual; + function GetSelections: TPersistentSelectionList{IDesignerSelections}; virtual; public function AllEqual: Boolean; override; procedure Edit; override; @@ -552,7 +552,7 @@ type procedure ReceiveComponentNames(const S: string); function GetComponent(const AInterface: Pointer {IInterface}): TComponent; function GetComponentReference: TComponent; override; - function GetSelections: TComponentSelectionList{IDesignerSelections}; override; + function GetSelections: TPersistentSelectionList{IDesignerSelections}; override; public function AllEqual: Boolean; override; procedure GetValues(Proc: TGetStrProc); override; @@ -714,6 +714,8 @@ type { TListPropertyEditor A property editor with dynamic sub properties representing a list of objects. UNDER CONSTRUCTION by Mattias} + +// MWE: changed TObject to TPersistent, TObject decendants can't have properties TListPropertyEditor = class(TPropertyEditor) private @@ -726,6 +728,8 @@ type property SaveElementLock: integer read FSaveElementLock; protected // methods and variables usable for descendent property editors: + // MWE: hmm... don't like "public" objects + // TODO: change this ? SavedList: TObject; SavedElements: TList; SavedPropertyEditors: TList; @@ -749,12 +753,12 @@ type NewValue: ansistring); virtual; public constructor Create(Hook:TPropertyEditorHook; - ComponentList: TComponentSelectionList; APropCount:Integer); override; + APersistentList: TPersistentSelectionList; APropCount:Integer); override; destructor Destroy; override; function GetAttributes: TPropertyAttributes; override; function GetElementCount: integer; - function GetElement(Index: integer): TObject; - function GetElement(Element: TListElementPropertyEditor): TObject; + function GetElement(Index: integer): TPersistent; + function GetElement(Element: TListElementPropertyEditor): TPersistent; function GetElementPropEditor(Index: integer): TListElementPropertyEditor; procedure GetProperties(Proc: TGetPropEditProc); override; function GetValue: AnsiString; override; @@ -845,9 +849,13 @@ type TPropertyEditorFilterFunc = function(const ATestEditor: TPropertyEditor): Boolean of object; -procedure GetComponentProperties(Components: TComponentSelectionList; - Filter: TTypeKinds; Hook: TPropertyEditorHook; Proc: TGetPropEditProc; - EditorFilterFunc: TPropertyEditorFilterFunc); +procedure GetPersistentProperties(ASelection: TPersistentSelectionList; + AFilter: TTypeKinds; AHook: TPropertyEditorHook; AProc: TGetPropEditProc; + AEditorFilterFunc: TPropertyEditorFilterFunc); + +procedure GetPersistentProperties(AItem: TPersistent; + AFilter: TTypeKinds; AHook: TPropertyEditorHook; AProc: TGetPropEditProc; + AEditorFilterFunc: TPropertyEditorFilterFunc); function GetEditorClass(PropInfo:PPropInfo; Obj:TPersistent): TPropertyEditorClass; @@ -860,17 +868,17 @@ procedure UpdateListPropertyEditors(AnObject: TObject); //============================================================================== { - The TComponentSelectionList is simply a list of TComponents references. - It will never create or free any components. It is used by the property + The TPersistentSelectionList is simply a list of TPersistent references. + It will never create or free any object. It is used by the property editors, the object inspector and the form editor. } type - TComponentSelectionList = class + TPersistentSelectionList = class protected FUpdateLock: integer; - FComponents: TList; - function GetItems(Index: integer): TComponent; - procedure SetItems(Index: integer; const CompValue: TComponent); + FPersistentList: TList; + function GetItems(AIndex: integer): TPersistent; + procedure SetItems(AIndex: integer; const APersistent: TPersistent); function GetCount: integer; function GetCapacity:integer; procedure SetCapacity(const NewCapacity:integer); @@ -882,23 +890,23 @@ type function UpdateLock: integer; function IndexOf(APersistent: TPersistent): integer; procedure Clear; - function IsEqual(SourceSelectionList: TComponentSelectionList): boolean; + function IsEqual(SourceSelectionList: TPersistentSelectionList): boolean; property Count:integer read GetCount; property Capacity:integer read GetCapacity write SetCapacity; - function Add(AComponent: TComponent): integer; - procedure Assign(SourceSelectionList: TComponentSelectionList); - property Items[Index: integer]: TComponent read GetItems write SetItems; default; + function Add(APersistent: TPersistent): integer; + procedure Assign(SourceSelectionList: TPersistentSelectionList); + property Items[AIndex: integer]: TPersistent read GetItems write SetItems; default; end; TBackupComponentList = class private FComponentList: TList; FLookupRoot: TPersistent; - FSelection: TComponentSelectionList; + FSelection: TPersistentSelectionList; function GetComponents(Index: integer): TComponent; procedure SetComponents(Index: integer; const AValue: TComponent); procedure SetLookupRoot(const AValue: TPersistent); - procedure SetSelection(const AValue: TComponentSelectionList); + procedure SetSelection(const AValue: TPersistentSelectionList); protected public constructor Create; @@ -907,11 +915,11 @@ type procedure Clear; function ComponentCount: integer; function IsEqual(ALookupRoot: TPersistent; - ASelection: TComponentSelectionList): boolean; + ASelection: TPersistentSelectionList): boolean; public property LookupRoot: TPersistent read FLookupRoot write SetLookupRoot; property Components[Index: integer]: TComponent read GetComponents write SetComponents; - property Selection: TComponentSelectionList read FSelection write SetSelection; + property Selection: TPersistentSelectionList read FSelection write SetSelection; end; //============================================================================== @@ -950,7 +958,7 @@ type ) of object; TPropHookComponentDeleting = procedure(AComponent: TComponent) of object; TPropHookDeleteComponent = procedure(var AComponent: TComponent) of object; - TPropHookGetSelectedComponents = procedure(Selection: TComponentSelectionList + TPropHookGetSelection = procedure(const ASelection: TPersistentSelectionList ) of object; // persistent objects TPropHookGetObject = function(const Name:ShortString):TPersistent of object; @@ -1037,7 +1045,7 @@ type procedure ComponentAdded(AComponent: TComponent; Select: boolean); procedure ComponentDeleting(AComponent: TComponent); procedure DeleteComponent(var AComponent: TComponent); - procedure GetSelectedComponents(Selection: TComponentSelectionList); + procedure GetSelection(const ASelection: TPersistentSelectionList); // persistent objects function GetObject(const Name: ShortString):TPersistent; function GetObjectName(Instance: TPersistent):ShortString; @@ -1048,90 +1056,101 @@ type procedure RefreshPropertyValues; public // Handlers - procedure RemoveAllHandlersForObject(HandlerObject: TObject); + procedure RemoveAllHandlersForObject(const HandlerObject: TObject); // lookup root procedure AddHandlerChangeLookupRoot( - OnChangeLookupRoot: TPropHookChangeLookupRoot); + const OnChangeLookupRoot: TPropHookChangeLookupRoot); procedure RemoveHandlerChangeLookupRoot( - OnChangeLookupRoot: TPropHookChangeLookupRoot); + const OnChangeLookupRoot: TPropHookChangeLookupRoot); // method events - procedure AddHandlerCreateMethod(OnCreateMethod: TPropHookCreateMethod); - procedure RemoveHandlerCreateMethod(OnCreateMethod: TPropHookCreateMethod); - procedure AddHandlerGetMethodName(OnGetMethodName: TPropHookGetMethodName); - procedure RemoveHandlerGetMethodName(OnGetMethodName: TPropHookGetMethodName); - procedure AddHandlerGetMethods(OnGetMethods: TPropHookGetMethods); - procedure RemoveHandlerGetMethods(OnGetMethods: TPropHookGetMethods); - procedure AddHandlerMethodExists(OnMethodExists: TPropHookMethodExists); - procedure RemoveHandlerMethodExists(OnMethodExists: TPropHookMethodExists); - procedure AddHandlerRenameMethod(OnRenameMethod: TPropHookRenameMethod); - procedure RemoveHandlerRenameMethod(OnRenameMethod: TPropHookRenameMethod); - procedure AddHandlerShowMethod(OnShowMethod: TPropHookShowMethod); - procedure RemoveHandlerShowMethod(OnShowMethod: TPropHookShowMethod); + procedure AddHandlerCreateMethod( + const OnCreateMethod: TPropHookCreateMethod); + procedure RemoveHandlerCreateMethod( + const OnCreateMethod: TPropHookCreateMethod); + procedure AddHandlerGetMethodName( + const OnGetMethodName: TPropHookGetMethodName); + procedure RemoveHandlerGetMethodName( + const OnGetMethodName: TPropHookGetMethodName); + procedure AddHandlerGetMethods(const OnGetMethods: TPropHookGetMethods); + procedure RemoveHandlerGetMethods(const OnGetMethods: TPropHookGetMethods); + procedure AddHandlerMethodExists( + const OnMethodExists: TPropHookMethodExists); + procedure RemoveHandlerMethodExists( + const OnMethodExists: TPropHookMethodExists); + procedure AddHandlerRenameMethod( + const OnRenameMethod: TPropHookRenameMethod); + procedure RemoveHandlerRenameMethod( + const OnRenameMethod: TPropHookRenameMethod); + procedure AddHandlerShowMethod(const OnShowMethod: TPropHookShowMethod); + procedure RemoveHandlerShowMethod(const OnShowMethod: TPropHookShowMethod); procedure AddHandlerMethodFromAncestor( - OnMethodFromAncestor: TPropHookMethodFromAncestor); + const OnMethodFromAncestor: TPropHookMethodFromAncestor); procedure RemoveHandlerMethodFromAncestor( - OnMethodFromAncestor: TPropHookMethodFromAncestor); - procedure AddHandlerChainCall(OnChainCall: TPropHookChainCall); - procedure RemoveHandlerChainCall(OnChainCall: TPropHookChainCall); + const OnMethodFromAncestor: TPropHookMethodFromAncestor); + procedure AddHandlerChainCall(const OnChainCall: TPropHookChainCall); + procedure RemoveHandlerChainCall(const OnChainCall: TPropHookChainCall); // component event - procedure AddHandlerGetComponent(OnGetComponent: TPropHookGetComponent); - procedure RemoveHandlerGetComponent(OnGetComponent: TPropHookGetComponent); + procedure AddHandlerGetComponent( + const OnGetComponent: TPropHookGetComponent); + procedure RemoveHandlerGetComponent( + const OnGetComponent: TPropHookGetComponent); procedure AddHandlerGetComponentName( - OnGetComponentName: TPropHookGetComponentName); + const OnGetComponentName: TPropHookGetComponentName); procedure RemoveHandlerGetComponentName( - OnGetComponentName: TPropHookGetComponentName); + const OnGetComponentName: TPropHookGetComponentName); procedure AddHandlerGetComponentNames( - OnGetComponentNames: TPropHookGetComponentNames); + const OnGetComponentNames: TPropHookGetComponentNames); procedure RemoveHandlerGetComponentNames( - OnGetComponentNames: TPropHookGetComponentNames); + const OnGetComponentNames: TPropHookGetComponentNames); procedure AddHandlerGetRootClassName( - OnGetRootClassName: TPropHookGetRootClassName); + const OnGetRootClassName: TPropHookGetRootClassName); procedure RemoveHandlerGetRootClassName( - OnGetRootClassName: TPropHookGetRootClassName); + const OnGetRootClassName: TPropHookGetRootClassName); procedure AddHandlerBeforeAddComponent( - OnBeforeAddComponent: TPropHookBeforeAddComponent); + const OnBeforeAddComponent: TPropHookBeforeAddComponent); procedure RemoveHandlerBeforeAddComponent( - OnBeforeAddComponent: TPropHookBeforeAddComponent); + const OnBeforeAddComponent: TPropHookBeforeAddComponent); procedure AddHandlerComponentRenamed( - OnComponentRenamed: TPropHookComponentRenamed); + const OnComponentRenamed: TPropHookComponentRenamed); procedure RemoveHandlerComponentRenamed( - OnComponentRenamed: TPropHookComponentRenamed); + const OnComponentRenamed: TPropHookComponentRenamed); procedure AddHandlerComponentAdded( - OnComponentAdded: TPropHookComponentAdded); + const OnComponentAdded: TPropHookComponentAdded); procedure RemoveHandlerComponentAdded( - OnComponentAdded: TPropHookComponentAdded); + const OnComponentAdded: TPropHookComponentAdded); procedure AddHandlerComponentDeleting( - OnComponentDeleting: TPropHookComponentDeleting); + const OnComponentDeleting: TPropHookComponentDeleting); procedure RemoveHandlerComponentDeleting( - OnComponentDeleting: TPropHookComponentDeleting); + const OnComponentDeleting: TPropHookComponentDeleting); procedure AddHandlerDeleteComponent( - OnDeleteComponent: TPropHookDeleteComponent); + const OnDeleteComponent: TPropHookDeleteComponent); procedure RemoveHandlerDeleteComponent( - OnDeleteComponent: TPropHookDeleteComponent); - procedure AddHandlerGetSelectedComponents( - OnGetSelectedComponents: TPropHookGetSelectedComponents); - procedure RemoveHandlerGetSelectedComponents( - OnGetSelectedComponents: TPropHookGetSelectedComponents); + const OnDeleteComponent: TPropHookDeleteComponent); + procedure AddHandlerGetSelection( + const OnGetSelection: TPropHookGetSelection); + procedure RemoveHandlerGetSelection( + const OnGetSelection: TPropHookGetSelection); // persistent object events - procedure AddHandlerGetObject(OnGetObject: TPropHookGetObject); - procedure RemoveHandlerGetObject(OnGetObject: TPropHookGetObject); - procedure AddHandlerGetObjectName(OnGetObjectName: TPropHookGetObjectName); + procedure AddHandlerGetObject(const OnGetObject: TPropHookGetObject); + procedure RemoveHandlerGetObject(const OnGetObject: TPropHookGetObject); + procedure AddHandlerGetObjectName( + const OnGetObjectName: TPropHookGetObjectName); procedure RemoveHandlerGetObjectName( - OnGetObjectName: TPropHookGetObjectName); + const OnGetObjectName: TPropHookGetObjectName); procedure AddHandlerGetObjectNames( - OnGetObjectNames: TPropHookGetObjectNames); + const OnGetObjectNames: TPropHookGetObjectNames); procedure RemoveHandlerGetObjectNames( - OnGetObjectNames: TPropHookGetObjectNames); + const OnGetObjectNames: TPropHookGetObjectNames); // modifing events - procedure AddHandlerModified(OnModified: TPropHookModified); - procedure RemoveHandlerModified(OnModified: TPropHookModified); - procedure AddHandlerRevert(OnRevert: TPropHookRevert); - procedure RemoveHandlerRevert(OnRevert: TPropHookRevert); + procedure AddHandlerModified(const OnModified: TPropHookModified); + procedure RemoveHandlerModified(const OnModified: TPropHookModified); + procedure AddHandlerRevert(const OnRevert: TPropHookRevert); + procedure RemoveHandlerRevert(const OnRevert: TPropHookRevert); procedure AddHandlerRefreshPropertyValues( - OnRefreshPropertyValues: TPropHookRefreshPropertyValues); + const OnRefreshPropertyValues: TPropHookRefreshPropertyValues); procedure RemoveHandlerRefreshPropertyValues( - OnRefreshPropertyValues: TPropHookRefreshPropertyValues); + const OnRefreshPropertyValues: TPropHookRefreshPropertyValues); end; function GetLookupRootForComponent(APersistent: TPersistent): TPersistent; @@ -1547,27 +1566,27 @@ begin end; end; -procedure GetComponentProperties(Components: TComponentSelectionList; - Filter: TTypeKinds; Hook: TPropertyEditorHook; Proc: TGetPropEditProc; - EditorFilterFunc: TPropertyEditorFilterFunc); +procedure GetPersistentProperties(ASelection: TPersistentSelectionList; + AFilter: TTypeKinds; AHook: TPropertyEditorHook; AProc: TGetPropEditProc; + AEditorFilterFunc: TPropertyEditorFilterFunc); var - I, J, CompCount: Integer; - CompType: TClass; + I, J, SelCount: Integer; + ClassTyp: TClass; Candidates: TPropInfoList; PropLists: TList; PropEditor: TPropertyEditor; EdClass: TPropertyEditorClass; PropInfo: PPropInfo; AddEditor: Boolean; - Obj: TComponent; + Instance: TPersistent; begin - if (Components = nil) or (Components.Count = 0) then Exit; - CompCount := Components.Count; - Obj := Components[0]; - CompType := Components[0].ClassType; + if (ASelection = nil) or (ASelection.Count = 0) then Exit; + SelCount := ASelection.Count; + Instance := ASelection[0]; + ClassTyp := Instance.ClassType; // Create a property candidate list of all properties that can be found in // every component in the list and in the Filter - Candidates := TPropInfoList.Create(Components[0], Filter); + Candidates := TPropInfoList.Create(Instance, AFilter); try // check each property candidate for I := Candidates.Count - 1 downto 0 do @@ -1579,60 +1598,66 @@ begin and (PropInfo^.SetProc = nil))) then begin Candidates.Delete(I); - continue; + Continue; end; - EdClass := GetEditorClass(PropInfo, Obj); - if EdClass = nil then begin - Candidates.Delete(I) - end else - begin - // create a test property editor for the property - PropEditor := EdClass.Create(Hook,Components,1); - PropEditor.SetPropEntry(0, Components[0], PropInfo); - PropEditor.Initialize; - with PropInfo^ do begin - // check for multiselection, ValueAvailable and customfilter - if ((CompCount > 1) - and not (paMultiSelect in PropEditor.GetAttributes)) - or not PropEditor.ValueAvailable - or (Assigned(EditorFilterFunc) and not EditorFilterFunc(PropEditor)) - then begin - Candidates.Delete(I); - end; + + EdClass := GetEditorClass(PropInfo, Instance); + if EdClass = nil + then begin + Candidates.Delete(I); + Continue; + end; + + // create a test property editor for the property + PropEditor := EdClass.Create(AHook,ASelection,1); + PropEditor.SetPropEntry(0, Instance, PropInfo); + PropEditor.Initialize; +// with PropInfo^ do begin + // check for multiselection, ValueAvailable and customfilter + if ((SelCount > 1) + and not (paMultiSelect in PropEditor.GetAttributes)) + or not PropEditor.ValueAvailable + or (Assigned(AEditorFilterFunc) and not AEditorFilterFunc(PropEditor)) + then begin + Candidates.Delete(I); end; - PropEditor.Free; - end; +// end; + PropEditor.Free; end; + PropLists := TList.Create; try - PropLists.Capacity := CompCount; + PropLists.Count := SelCount; // Create a property info list for each component in the selection - for I := 0 to CompCount - 1 do - PropLists.Add(TPropInfoList.Create(Components[I], Filter)); + for I := 0 to SelCount - 1 do + PropLists[i] := TPropInfoList.Create(ASelection[I], AFilter); + // Eliminate each property in Candidates that is not in all property lists - for I := 0 to CompCount - 1 do + for I := 0 to SelCount - 1 do Candidates.Intersect(TPropInfoList(PropLists[I])); + // Eliminate each property in the property list that are not in Candidates - for I := 0 to CompCount - 1 do + for I := 0 to SelCount - 1 do TPropInfoList(PropLists[I]).Intersect(Candidates); + // PropList now has a matrix of PropInfo's. // -> create a property editor for each property for I := 0 to Candidates.Count - 1 do begin - EdClass := GetEditorClass(Candidates[I], Obj); + EdClass := GetEditorClass(Candidates[I], Instance); if EdClass = nil then Continue; - PropEditor := EdClass.Create(Hook, Components, CompCount); + PropEditor := EdClass.Create(AHook, ASelection, SelCount); AddEditor := True; - for J := 0 to CompCount - 1 do + for J := 0 to SelCount - 1 do begin - if (Components[J].ClassType <> CompType) and + if (ASelection[J].ClassType <> ClassTyp) and (GetEditorClass(TPropInfoList(PropLists[J])[I], - Components[J]) <> EdClass) then + ASelection[J]) <> EdClass) then begin AddEditor := False; Break; end; - PropEditor.SetPropEntry(J, Components[J], + PropEditor.SetPropEntry(J, ASelection[J], TPropInfoList(PropLists[J])[I]); end; if AddEditor then @@ -1641,7 +1666,7 @@ begin if not PropEditor.ValueAvailable then AddEditor:=false; end; if AddEditor then - Proc(PropEditor) + AProc(PropEditor) else PropEditor.Free; end; @@ -1654,14 +1679,30 @@ begin end; end; +procedure GetPersistentProperties(AItem: TPersistent; + AFilter: TTypeKinds; AHook: TPropertyEditorHook; AProc: TGetPropEditProc; + AEditorFilterFunc: TPropertyEditorFilterFunc); +var + Selection: TPersistentSelectionList; +begin + if AItem = nil then Exit; + Selection := TPersistentSelectionList.Create; + try + Selection.Add(AItem); + GetPersistentProperties(Selection, AFilter, AHook, AProc, AEditorFilterFunc); + finally + Selection.Free; + end; +end; + { TPropertyEditor } constructor TPropertyEditor.Create(Hook: TPropertyEditorHook; - ComponentList: TComponentSelectionList; APropCount:Integer); + APersistentList: TPersistentSelectionList; APropCount:Integer); begin FPropertyHook:=Hook; - FComponents:=ComponentList; + FComponents:=APersistentList; GetMem(FPropList,APropCount * SizeOf(TInstProp)); FPropCount:=APropCount; end; @@ -2799,7 +2840,7 @@ begin Result:=ReadElementCount; end; -function TListPropertyEditor.GetElement(Index: integer): TObject; +function TListPropertyEditor.GetElement(Index: integer): TPersistent; var ElementCount: integer; begin @@ -2812,13 +2853,13 @@ begin +' Count='+IntToStr(ElementCount)); // get element if not IsSaving then - Result:=TObject(SavedElements[Index]) + Result:=TPersistent(SavedElements[Index]) else Result:=ReadElement(Index); end; function TListPropertyEditor.GetElement(Element: TListElementPropertyEditor - ): TObject; + ): TPersistent; begin Result:=GetElement(Element.TheIndex); end; @@ -2851,7 +2892,7 @@ begin if SavedList<>GetComponent(0) then exit; if ReadElementCount<>SavedElements.Count then exit; for i:=0 to SavedElements.Count-1 do - if TObject(SavedElements[i])<>ReadElement(i) then exit; + if TPersistent(SavedElements[i])<>ReadElement(i) then exit; Result:=false; FSubPropertiesChanged:=false; end; @@ -2956,9 +2997,9 @@ begin end; constructor TListPropertyEditor.Create(Hook: TPropertyEditorHook; - ComponentList: TComponentSelectionList; APropCount: Integer); + APersistentList: TPersistentSelectionList; APropCount: Integer); begin - inherited Create(Hook, ComponentList, APropCount); + inherited Create(Hook, APersistentList, APropCount); SavedElements:=TList.Create; SavedPropertyEditors:=TList.Create; end; @@ -3162,13 +3203,8 @@ end; procedure TCollectionPropertyEditor.GetElementProperties( Element: TListElementPropertyEditor; Proc: TGetPropEditProc); -var - Components: TComponentSelectionList; begin - Components := TComponentSelectionList.Create; - Components.Add(TComponent(GetElement(Element))); - GetComponentProperties(Components,tkProperties,PropertyHook,Proc,nil); - Components.Free; + GetPersistentProperties(GetElement(Element),tkProperties,PropertyHook,Proc,nil); end; function TCollectionPropertyEditor.GetElementValue( @@ -3228,19 +3264,19 @@ end; procedure TClassPropertyEditor.GetProperties(Proc: TGetPropEditProc); var I: Integer; - SubComponent: TComponent; - Components: TComponentSelectionList; + SubItem: TPersistent; + Selection: TPersistentSelectionList; begin - Components := TComponentSelectionList.Create; + Selection := TPersistentSelectionList.Create; try for I := 0 to PropCount - 1 do begin - SubComponent:=TComponent(GetOrdValueAt(I)); - if SubComponent<>nil then - Components.Add(SubComponent); + SubItem := TPersistent(GetOrdValueAt(I)); + if SubItem<>nil then + Selection.Add(SubItem); end; - GetComponentProperties(Components,tkProperties,PropertyHook,Proc,nil); + GetPersistentProperties(Selection,tkProperties,PropertyHook,Proc,nil); finally - Components.Free; + Selection.Free; end; end; @@ -3455,14 +3491,14 @@ begin end; function TComponentPropertyEditor.GetSelections: - TComponentSelectionList{IDesignerSelections}; + TPersistentSelectionList{IDesignerSelections}; var I: Integer; begin Result := nil; if (GetComponentReference <> nil) and AllEqual then begin - Result := TComponentSelectionList.Create; + Result := TPersistentSelectionList.Create; for I := 0 to PropCount - 1 do Result.Add(TComponent(GetOrdValueAt(I))); end; @@ -3512,7 +3548,7 @@ end; procedure TComponentPropertyEditor.GetProperties(Proc:TGetPropEditProc); var - LComponents: TComponentSelectionList; + LComponents: TPersistentSelectionList; //LDesigner: TIDesigner; begin LComponents := GetSelections; @@ -3520,7 +3556,7 @@ begin begin //if not Supports(FindRootDesigner(LComponents[0]), IDesigner, LDesigner) then // LDesigner := Designer; - GetComponentProperties(LComponents, tkAny, PropertyHook, Proc, nil); + GetPersistentProperties(LComponents, tkAny, PropertyHook, Proc, nil); end; end; @@ -3600,7 +3636,7 @@ begin Result := nil; //GetComponent(GetIntfValue); end; -function TInterfaceProperty.GetSelections: TComponentSelectionList{IDesignerSelections}; +function TInterfaceProperty.GetSelections: TPersistentSelectionList{IDesignerSelections}; {var I: Integer;} begin @@ -4234,98 +4270,104 @@ end; //============================================================================== -{ TComponentSelectionList } +{ TPersistentSelectionList } -function TComponentSelectionList.Add(AComponent: TComponent): integer; +function TPersistentSelectionList.Add(APersistent: TPersistent): integer; begin - Result:=FComponents.Add(AComponent); + Result:=FPersistentList.Add(APersistent); end; -procedure TComponentSelectionList.Clear; +procedure TPersistentSelectionList.Clear; begin - FComponents.Clear; + FPersistentList.Clear; end; -constructor TComponentSelectionList.Create; +constructor TPersistentSelectionList.Create; begin inherited Create; - FComponents:=TList.Create; + FPersistentList:=TList.Create; end; -destructor TComponentSelectionList.Destroy; +destructor TPersistentSelectionList.Destroy; begin - FComponents.Free; + FreeAndNil(FPersistentList); inherited Destroy; end; -function TComponentSelectionList.GetCount: integer; +function TPersistentSelectionList.GetCount: integer; begin - Result:=FComponents.Count; + Result:=FPersistentList.Count; end; -function TComponentSelectionList.GetItems(Index: integer): TComponent; +function TPersistentSelectionList.GetItems(AIndex: integer): TPersistent; begin - Result:=TComponent(FComponents[Index]); + Result:=TPersistent(FPersistentList[AIndex]); end; -procedure TComponentSelectionList.SetItems(Index: integer; - const CompValue: TComponent); +procedure TPersistentSelectionList.SetItems(AIndex: integer; + const APersistent: TPersistent); begin - FComponents[Index]:=CompValue; + FPersistentList[AIndex]:=APersistent; end; -function TComponentSelectionList.GetCapacity:integer; +function TPersistentSelectionList.GetCapacity:integer; begin - Result:=FComponents.Capacity; + Result:=FPersistentList.Capacity; end; -procedure TComponentSelectionList.SetCapacity(const NewCapacity:integer); +procedure TPersistentSelectionList.SetCapacity(const NewCapacity:integer); begin - FComponents.Capacity:=NewCapacity; + FPersistentList.Capacity:=NewCapacity; end; -procedure TComponentSelectionList.BeginUpdate; +procedure TPersistentSelectionList.BeginUpdate; begin inc(FUpdateLock); end; -procedure TComponentSelectionList.EndUpdate; +procedure TPersistentSelectionList.EndUpdate; begin dec(FUpdateLock); end; -function TComponentSelectionList.UpdateLock: integer; +function TPersistentSelectionList.UpdateLock: integer; begin Result:=FUpdateLock; end; -function TComponentSelectionList.IndexOf(APersistent: TPersistent): integer; +function TPersistentSelectionList.IndexOf(APersistent: TPersistent): integer; begin Result:=Count-1; while (Result>=0) and (Items[Result]<>APersistent) do dec(Result); end; -procedure TComponentSelectionList.Assign( - SourceSelectionList:TComponentSelectionList); +procedure TPersistentSelectionList.Assign( + SourceSelectionList:TPersistentSelectionList); var a:integer; begin if SourceSelectionList=Self then exit; Clear; if (SourceSelectionList<>nil) and (SourceSelectionList.Count>0) then begin - FComponents.Capacity:=SourceSelectionList.Count; + FPersistentList.Count:=SourceSelectionList.Count; for a:=0 to SourceSelectionList.Count-1 do - Add(SourceSelectionList[a]); + FPersistentList[a] := SourceSelectionList[a]; + + // Even faster would have been: + // Move(SourceSelectionList.FPersistentList.List^, FPersistentList.List^, FPersistentList.Count * SizeOf(Pointer)); end; end; -function TComponentSelectionList.IsEqual( - SourceSelectionList:TComponentSelectionList):boolean; +function TPersistentSelectionList.IsEqual( + SourceSelectionList:TPersistentSelectionList):boolean; var a:integer; begin Result:=false; - if FComponents.Count<>SourceSelectionList.Count then exit; - for a:=0 to FComponents.Count-1 do + if FPersistentList.Count<>SourceSelectionList.Count then exit; + for a:=0 to FPersistentList.Count-1 do if Items[a]<>SourceSelectionList[a] then exit; + + // Even faster would have been: + // Result := CompareDWord(SourceSelectionList.FPersistentList.List^, FPersistentList.List^, FPersistentList.Count); Result:=true; end; @@ -4583,18 +4625,17 @@ begin FreeThenNil(AComponent); end; -procedure TPropertyEditorHook.GetSelectedComponents( - Selection: TComponentSelectionList); +procedure TPropertyEditorHook.GetSelection(const ASelection: TPersistentSelectionList); var i: Integer; - Handler: TPropHookGetSelectedComponents; + Handler: TPropHookGetSelection; begin - if Selection=nil then exit; - Selection.Clear; + if ASelection=nil then exit; + ASelection.Clear; i:=GetHandlerCount(htGetSelectedComponents); while GetNextHandlerIndex(htGetSelectedComponents,i) do begin - Handler:=TPropHookGetSelectedComponents(FHandlers[htGetSelectedComponents][i]); - Handler(Selection); + Handler:=TPropHookGetSelection(FHandlers[htGetSelectedComponents][i]); + Handler(ASelection); end; end; @@ -4666,7 +4707,7 @@ begin TPropHookRefreshPropertyValues(FHandlers[htRefreshPropertyValues][i])(); end; -procedure TPropertyEditorHook.RemoveAllHandlersForObject(HandlerObject: TObject +procedure TPropertyEditorHook.RemoveAllHandlersForObject(const HandlerObject: TObject ); var HookType: TPropHookType; @@ -4677,299 +4718,299 @@ begin end; procedure TPropertyEditorHook.AddHandlerChangeLookupRoot( - OnChangeLookupRoot: TPropHookChangeLookupRoot); + const OnChangeLookupRoot: TPropHookChangeLookupRoot); begin AddHandler(htChangeLookupRoot,TMethod(OnChangeLookupRoot)); end; procedure TPropertyEditorHook.RemoveHandlerChangeLookupRoot( - OnChangeLookupRoot: TPropHookChangeLookupRoot); + const OnChangeLookupRoot: TPropHookChangeLookupRoot); begin RemoveHandler(htChangeLookupRoot,TMethod(OnChangeLookupRoot)); end; procedure TPropertyEditorHook.AddHandlerCreateMethod( - OnCreateMethod: TPropHookCreateMethod); + const OnCreateMethod: TPropHookCreateMethod); begin AddHandler(htCreateMethod,TMethod(OnCreateMethod)); end; procedure TPropertyEditorHook.RemoveHandlerCreateMethod( - OnCreateMethod: TPropHookCreateMethod); + const OnCreateMethod: TPropHookCreateMethod); begin RemoveHandler(htCreateMethod,TMethod(OnCreateMethod)); end; procedure TPropertyEditorHook.AddHandlerGetMethodName( - OnGetMethodName: TPropHookGetMethodName); + const OnGetMethodName: TPropHookGetMethodName); begin AddHandler(htGetMethodName,TMethod(OnGetMethodName)); end; procedure TPropertyEditorHook.RemoveHandlerGetMethodName( - OnGetMethodName: TPropHookGetMethodName); + const OnGetMethodName: TPropHookGetMethodName); begin RemoveHandler(htGetMethodName,TMethod(OnGetMethodName)); end; procedure TPropertyEditorHook.AddHandlerGetMethods( - OnGetMethods: TPropHookGetMethods); + const OnGetMethods: TPropHookGetMethods); begin AddHandler(htGetMethods,TMethod(OnGetMethods)); end; procedure TPropertyEditorHook.RemoveHandlerGetMethods( - OnGetMethods: TPropHookGetMethods); + const OnGetMethods: TPropHookGetMethods); begin RemoveHandler(htGetMethods,TMethod(OnGetMethods)); end; procedure TPropertyEditorHook.AddHandlerMethodExists( - OnMethodExists: TPropHookMethodExists); + const OnMethodExists: TPropHookMethodExists); begin AddHandler(htMethodExists,TMethod(OnMethodExists)); end; procedure TPropertyEditorHook.RemoveHandlerMethodExists( - OnMethodExists: TPropHookMethodExists); + const OnMethodExists: TPropHookMethodExists); begin RemoveHandler(htMethodExists,TMethod(OnMethodExists)); end; procedure TPropertyEditorHook.AddHandlerRenameMethod( - OnRenameMethod: TPropHookRenameMethod); + const OnRenameMethod: TPropHookRenameMethod); begin AddHandler(htRenameMethod,TMethod(OnRenameMethod)); end; procedure TPropertyEditorHook.RemoveHandlerRenameMethod( - OnRenameMethod: TPropHookRenameMethod); + const OnRenameMethod: TPropHookRenameMethod); begin RemoveHandler(htRenameMethod,TMethod(OnRenameMethod)); end; procedure TPropertyEditorHook.AddHandlerShowMethod( - OnShowMethod: TPropHookShowMethod); + const OnShowMethod: TPropHookShowMethod); begin AddHandler(htShowMethod,TMethod(OnShowMethod)); end; procedure TPropertyEditorHook.RemoveHandlerShowMethod( - OnShowMethod: TPropHookShowMethod); + const OnShowMethod: TPropHookShowMethod); begin RemoveHandler(htShowMethod,TMethod(OnShowMethod)); end; procedure TPropertyEditorHook.AddHandlerMethodFromAncestor( - OnMethodFromAncestor: TPropHookMethodFromAncestor); + const OnMethodFromAncestor: TPropHookMethodFromAncestor); begin AddHandler(htMethodFromAncestor,TMethod(OnMethodFromAncestor)); end; procedure TPropertyEditorHook.RemoveHandlerMethodFromAncestor( - OnMethodFromAncestor: TPropHookMethodFromAncestor); + const OnMethodFromAncestor: TPropHookMethodFromAncestor); begin RemoveHandler(htMethodFromAncestor,TMethod(OnMethodFromAncestor)); end; procedure TPropertyEditorHook.AddHandlerChainCall( - OnChainCall: TPropHookChainCall); + const OnChainCall: TPropHookChainCall); begin AddHandler(htChainCall,TMethod(OnChainCall)); end; procedure TPropertyEditorHook.RemoveHandlerChainCall( - OnChainCall: TPropHookChainCall); + const OnChainCall: TPropHookChainCall); begin RemoveHandler(htChainCall,TMethod(OnChainCall)); end; procedure TPropertyEditorHook.AddHandlerGetComponent( - OnGetComponent: TPropHookGetComponent); + const OnGetComponent: TPropHookGetComponent); begin AddHandler(htGetComponent,TMethod(OnGetComponent)); end; procedure TPropertyEditorHook.RemoveHandlerGetComponent( - OnGetComponent: TPropHookGetComponent); + const OnGetComponent: TPropHookGetComponent); begin RemoveHandler(htGetComponent,TMethod(OnGetComponent)); end; procedure TPropertyEditorHook.AddHandlerGetComponentName( - OnGetComponentName: TPropHookGetComponentName); + const OnGetComponentName: TPropHookGetComponentName); begin AddHandler(htGetComponentName,TMethod(OnGetComponentName)); end; procedure TPropertyEditorHook.RemoveHandlerGetComponentName( - OnGetComponentName: TPropHookGetComponentName); + const OnGetComponentName: TPropHookGetComponentName); begin RemoveHandler(htGetComponentName,TMethod(OnGetComponentName)); end; procedure TPropertyEditorHook.AddHandlerGetComponentNames( - OnGetComponentNames: TPropHookGetComponentNames); + const OnGetComponentNames: TPropHookGetComponentNames); begin AddHandler(htGetComponentNames,TMethod(OnGetComponentNames)); end; procedure TPropertyEditorHook.RemoveHandlerGetComponentNames( - OnGetComponentNames: TPropHookGetComponentNames); + const OnGetComponentNames: TPropHookGetComponentNames); begin RemoveHandler(htGetComponentNames,TMethod(OnGetComponentNames)); end; procedure TPropertyEditorHook.AddHandlerGetRootClassName( - OnGetRootClassName: TPropHookGetRootClassName); + const OnGetRootClassName: TPropHookGetRootClassName); begin AddHandler(htGetRootClassName,TMethod(OnGetRootClassName)); end; procedure TPropertyEditorHook.RemoveHandlerGetRootClassName( - OnGetRootClassName: TPropHookGetRootClassName); + const OnGetRootClassName: TPropHookGetRootClassName); begin RemoveHandler(htGetRootClassName,TMethod(OnGetRootClassName)); end; procedure TPropertyEditorHook.AddHandlerBeforeAddComponent( - OnBeforeAddComponent: TPropHookBeforeAddComponent); + const OnBeforeAddComponent: TPropHookBeforeAddComponent); begin AddHandler(htBeforeAddComponent,TMethod(OnBeforeAddComponent)); end; procedure TPropertyEditorHook.RemoveHandlerBeforeAddComponent( - OnBeforeAddComponent: TPropHookBeforeAddComponent); + const OnBeforeAddComponent: TPropHookBeforeAddComponent); begin RemoveHandler(htBeforeAddComponent,TMethod(OnBeforeAddComponent)); end; procedure TPropertyEditorHook.AddHandlerComponentRenamed( - OnComponentRenamed: TPropHookComponentRenamed); + const OnComponentRenamed: TPropHookComponentRenamed); begin AddHandler(htComponentRenamed,TMethod(OnComponentRenamed)); end; procedure TPropertyEditorHook.RemoveHandlerComponentRenamed( - OnComponentRenamed: TPropHookComponentRenamed); + const OnComponentRenamed: TPropHookComponentRenamed); begin RemoveHandler(htComponentRenamed,TMethod(OnComponentRenamed)); end; procedure TPropertyEditorHook.AddHandlerComponentAdded( - OnComponentAdded: TPropHookComponentAdded); + const OnComponentAdded: TPropHookComponentAdded); begin AddHandler(htComponentAdded,TMethod(OnComponentAdded)); end; procedure TPropertyEditorHook.RemoveHandlerComponentAdded( - OnComponentAdded: TPropHookComponentAdded); + const OnComponentAdded: TPropHookComponentAdded); begin RemoveHandler(htComponentAdded,TMethod(OnComponentAdded)); end; procedure TPropertyEditorHook.AddHandlerComponentDeleting( - OnComponentDeleting: TPropHookComponentDeleting); + const OnComponentDeleting: TPropHookComponentDeleting); begin AddHandler(htComponentDeleting,TMethod(OnComponentDeleting)); end; procedure TPropertyEditorHook.RemoveHandlerComponentDeleting( - OnComponentDeleting: TPropHookComponentDeleting); + const OnComponentDeleting: TPropHookComponentDeleting); begin RemoveHandler(htComponentDeleting,TMethod(OnComponentDeleting)); end; procedure TPropertyEditorHook.AddHandlerDeleteComponent( - OnDeleteComponent: TPropHookDeleteComponent); + const OnDeleteComponent: TPropHookDeleteComponent); begin AddHandler(htDeleteComponent,TMethod(OnDeleteComponent)); end; procedure TPropertyEditorHook.RemoveHandlerDeleteComponent( - OnDeleteComponent: TPropHookDeleteComponent); + const OnDeleteComponent: TPropHookDeleteComponent); begin RemoveHandler(htDeleteComponent,TMethod(OnDeleteComponent)); end; -procedure TPropertyEditorHook.AddHandlerGetSelectedComponents( - OnGetSelectedComponents: TPropHookGetSelectedComponents); +procedure TPropertyEditorHook.AddHandlerGetSelection( + const OnGetSelection: TPropHookGetSelection); begin - AddHandler(htGetSelectedComponents,TMethod(OnGetSelectedComponents)); + AddHandler(htGetSelectedComponents,TMethod(OnGetSelection)); end; -procedure TPropertyEditorHook.RemoveHandlerGetSelectedComponents( - OnGetSelectedComponents: TPropHookGetSelectedComponents); +procedure TPropertyEditorHook.RemoveHandlerGetSelection( + const OnGetSelection: TPropHookGetSelection); begin - RemoveHandler(htGetSelectedComponents,TMethod(OnGetSelectedComponents)); + RemoveHandler(htGetSelectedComponents,TMethod(OnGetSelection)); end; procedure TPropertyEditorHook.AddHandlerGetObject( - OnGetObject: TPropHookGetObject); + const OnGetObject: TPropHookGetObject); begin AddHandler(htGetObject,TMethod(OnGetObject)); end; procedure TPropertyEditorHook.RemoveHandlerGetObject( - OnGetObject: TPropHookGetObject); + const OnGetObject: TPropHookGetObject); begin RemoveHandler(htGetObject,TMethod(OnGetObject)); end; procedure TPropertyEditorHook.AddHandlerGetObjectName( - OnGetObjectName: TPropHookGetObjectName); + const OnGetObjectName: TPropHookGetObjectName); begin AddHandler(htGetObjectName,TMethod(OnGetObjectName)); end; procedure TPropertyEditorHook.RemoveHandlerGetObjectName( - OnGetObjectName: TPropHookGetObjectName); + const OnGetObjectName: TPropHookGetObjectName); begin RemoveHandler(htGetObjectName,TMethod(OnGetObjectName)); end; procedure TPropertyEditorHook.AddHandlerGetObjectNames( - OnGetObjectNames: TPropHookGetObjectNames); + const OnGetObjectNames: TPropHookGetObjectNames); begin AddHandler(htGetObjectNames,TMethod(OnGetObjectNames)); end; procedure TPropertyEditorHook.RemoveHandlerGetObjectNames( - OnGetObjectNames: TPropHookGetObjectNames); + const OnGetObjectNames: TPropHookGetObjectNames); begin RemoveHandler(htGetObjectNames,TMethod(OnGetObjectNames)); end; -procedure TPropertyEditorHook.AddHandlerModified(OnModified: TPropHookModified - ); +procedure TPropertyEditorHook.AddHandlerModified( + const OnModified: TPropHookModified); begin AddHandler(htModified,TMethod(OnModified)); end; procedure TPropertyEditorHook.RemoveHandlerModified( - OnModified: TPropHookModified); + const OnModified: TPropHookModified); begin RemoveHandler(htModified,TMethod(OnModified)); end; -procedure TPropertyEditorHook.AddHandlerRevert(OnRevert: TPropHookRevert); +procedure TPropertyEditorHook.AddHandlerRevert(const OnRevert: TPropHookRevert); begin AddHandler(htRevert,TMethod(OnRevert)); end; -procedure TPropertyEditorHook.RemoveHandlerRevert(OnRevert: TPropHookRevert); +procedure TPropertyEditorHook.RemoveHandlerRevert(const OnRevert: TPropHookRevert); begin RemoveHandler(htRevert,TMethod(OnRevert)); end; procedure TPropertyEditorHook.AddHandlerRefreshPropertyValues( - OnRefreshPropertyValues: TPropHookRefreshPropertyValues); + const OnRefreshPropertyValues: TPropHookRefreshPropertyValues); begin AddHandler(htRefreshPropertyValues,TMethod(OnRefreshPropertyValues)); end; procedure TPropertyEditorHook.RemoveHandlerRefreshPropertyValues( - OnRefreshPropertyValues: TPropHookRefreshPropertyValues); + const OnRefreshPropertyValues: TPropHookRefreshPropertyValues); begin RemoveHandler(htRefreshPropertyValues,TMethod(OnRefreshPropertyValues)); end; @@ -5168,7 +5209,7 @@ begin end; procedure TBackupComponentList.SetSelection( - const AValue: TComponentSelectionList); + const AValue: TPersistentSelectionList); begin if FSelection=AValue then exit; FSelection.Assign(AValue); @@ -5176,7 +5217,7 @@ end; constructor TBackupComponentList.Create; begin - FSelection:=TComponentSelectionList.Create; + FSelection:=TPersistentSelectionList.Create; FComponentList:=TList.Create; end; @@ -5203,7 +5244,7 @@ begin end; function TBackupComponentList.IsEqual(ALookupRoot: TPersistent; - ASelection: TComponentSelectionList): boolean; + ASelection: TPersistentSelectionList): boolean; var i: Integer; begin