* Changed TComponentSelectionList to TPersistentSelectionList

+ Added SSHdebugger property

git-svn-id: trunk@5007 -
This commit is contained in:
marc 2004-01-04 03:53:36 +00:00
parent c38db1c277
commit 348cd5c298
14 changed files with 563 additions and 466 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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(

View File

@ -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;

View File

@ -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

View File

@ -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';

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -19,7 +19,7 @@ interface
resourcestring
//
oisObjectInspector = 'Object Inspector';
oisItemsSelected = ' items selected';
oisItemsSelected = '%u items selected';
oiscAdd = '&Add';
oiscDelete = '&Delete';

File diff suppressed because it is too large Load Diff