mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 19:52:26 +02:00
fixed TCollectionPropertyEditorForm to recognize renames and deletes
git-svn-id: trunk@6677 -
This commit is contained in:
parent
b2b2743b38
commit
481bc1c1e4
@ -1255,7 +1255,7 @@ begin
|
|||||||
Result:=MergeSearchPaths(CurrentPath,InheritedPath);
|
Result:=MergeSearchPaths(CurrentPath,InheritedPath);
|
||||||
{$IFDEF VerbosePkgUnitPath}
|
{$IFDEF VerbosePkgUnitPath}
|
||||||
if Option=pcosUnitPath then
|
if Option=pcosUnitPath then
|
||||||
debugln('TBaseCompilerOptions.GetParsedPath Total ',dbgsName(Self),' CurrentPath="',CurrentPath,'"');
|
debugln('TBaseCompilerOptions.GetParsedPath Total ',dbgsName(Self),' Result="',Result,'"');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2450,8 +2450,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPropertyEditor.Initialize;
|
procedure TPropertyEditor.Initialize;
|
||||||
|
|
||||||
|
procedure RaiseNoInstance;
|
||||||
|
begin
|
||||||
|
raise Exception.Create('TPropertyEditor.Initialize '+dbgsName(Self));
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
//
|
if FPropList^[0].Instance=nil then
|
||||||
|
RaiseNoInstance;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPropertyEditor.Modified;
|
procedure TPropertyEditor.Modified;
|
||||||
@ -3425,15 +3432,20 @@ begin
|
|||||||
SaveElements;
|
SaveElements;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCollectionPropertyEditor }
|
|
||||||
|
|
||||||
Type
|
Type
|
||||||
|
{ TCollectionPropertyEditor }
|
||||||
|
|
||||||
TCollectionPropertyEditorForm = class(TForm)
|
TCollectionPropertyEditorForm = class(TForm)
|
||||||
procedure ListClick(Sender: TObject);
|
procedure ListClick(Sender: TObject);
|
||||||
procedure AddClick(Sender: TObject);
|
procedure AddClick(Sender: TObject);
|
||||||
procedure DeleteClick(Sender: TObject);
|
procedure DeleteClick(Sender: TObject);
|
||||||
procedure MoveDownButtonClick(Sender: TObject);
|
procedure MoveDownButtonClick(Sender: TObject);
|
||||||
procedure MoveUpButtonClick(Sender: TObject);
|
procedure MoveUpButtonClick(Sender: TObject);
|
||||||
|
private
|
||||||
|
FCollection: TCollection;
|
||||||
|
FOwnerPersistent: TPersistent;
|
||||||
|
FPropertyName: string;
|
||||||
protected
|
protected
|
||||||
CollectionListBox: TListBox;
|
CollectionListBox: TListBox;
|
||||||
ButtonPanel: TPanel;
|
ButtonPanel: TPanel;
|
||||||
@ -3443,13 +3455,19 @@ Type
|
|||||||
MoveDownButton: TSpeedButton;
|
MoveDownButton: TSpeedButton;
|
||||||
procedure UpdateCaption;
|
procedure UpdateCaption;
|
||||||
procedure UpdateButtons;
|
procedure UpdateButtons;
|
||||||
|
procedure ComponentRenamed(AComponent: TComponent);
|
||||||
|
procedure PersistentDeleting(APersistent: TPersistent);
|
||||||
public
|
public
|
||||||
Collection: TCollection;
|
|
||||||
PersistentName: string;
|
|
||||||
PropertyName: string;
|
|
||||||
procedure FillCollectionListBox;
|
procedure FillCollectionListBox;
|
||||||
Constructor Create(TheOwner: TComponent); Override;
|
constructor Create(TheOwner: TComponent); Override;
|
||||||
|
destructor Destroy; override;
|
||||||
procedure SelectInObjectInspector(UnselectAll: boolean);
|
procedure SelectInObjectInspector(UnselectAll: boolean);
|
||||||
|
procedure SetCollection(NewCollection: TCollection;
|
||||||
|
NewOwnerPersistent: TPersistent; const NewPropName: string);
|
||||||
|
public
|
||||||
|
property Collection: TCollection read FCollection;
|
||||||
|
property OwnerPersistent: TPersistent read FOwnerPersistent;
|
||||||
|
property PropertyName: string read FPropertyName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -3537,12 +3555,19 @@ procedure TCollectionPropertyEditorForm.UpdateCaption;
|
|||||||
var
|
var
|
||||||
NewCaption: String;
|
NewCaption: String;
|
||||||
begin
|
begin
|
||||||
//I think to match Delphi this should be formated like
|
//I think to match Delphi this should be formatted like
|
||||||
//"Editing ComponentName.PropertyName[Index]"
|
//"Editing ComponentName.PropertyName[Index]"
|
||||||
NewCaption:= 'Editing ' + PersistentName + '.' + PropertyName;
|
if OwnerPersistent is TComponent then
|
||||||
|
NewCaption:=TComponent(OwnerPersistent).Name
|
||||||
|
else if OwnerPersistent<>nil then
|
||||||
|
NewCaption:=OwnerPersistent.GetNamePath
|
||||||
|
else
|
||||||
|
NewCaption:='';
|
||||||
|
if NewCaption<>'' then NewCaption:=NewCaption+'.';
|
||||||
|
NewCaption:=NewCaption+PropertyName;
|
||||||
|
NewCaption:= 'Editing ' + NewCaption;
|
||||||
If CollectionListBox.ItemIndex > -1 then
|
If CollectionListBox.ItemIndex > -1 then
|
||||||
NewCaption := NewCaption + '[' +
|
NewCaption:=NewCaption + '[' + IntToStr(CollectionListBox.ItemIndex) + ']';
|
||||||
IntToStr(CollectionListBox.ItemIndex) + ']';
|
|
||||||
Caption:=NewCaption;
|
Caption:=NewCaption;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3556,6 +3581,20 @@ begin
|
|||||||
MoveDownButton.Enabled:=(i>=0) and (i<Collection.Count-1);
|
MoveDownButton.Enabled:=(i>=0) and (i<Collection.Count-1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCollectionPropertyEditorForm.ComponentRenamed(AComponent: TComponent
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
if AComponent=OwnerPersistent then
|
||||||
|
UpdateCaption;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCollectionPropertyEditorForm.PersistentDeleting(
|
||||||
|
APersistent: TPersistent);
|
||||||
|
begin
|
||||||
|
if APersistent=OwnerPersistent then
|
||||||
|
SetCollection(nil,nil,'');
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.FillCollectionListBox;
|
procedure TCollectionPropertyEditorForm.FillCollectionListBox;
|
||||||
var
|
var
|
||||||
I : Longint;
|
I : Longint;
|
||||||
@ -3658,6 +3697,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TCollectionPropertyEditorForm.Destroy;
|
||||||
|
begin
|
||||||
|
if GlobalDesignHook<>nil then
|
||||||
|
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCollectionPropertyEditorForm.SelectInObjectInspector(
|
procedure TCollectionPropertyEditorForm.SelectInObjectInspector(
|
||||||
UnselectAll: boolean);
|
UnselectAll: boolean);
|
||||||
var
|
var
|
||||||
@ -3678,6 +3724,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCollectionPropertyEditorForm.SetCollection(
|
||||||
|
NewCollection: TCollection; NewOwnerPersistent: TPersistent;
|
||||||
|
const NewPropName: string);
|
||||||
|
begin
|
||||||
|
if (FCollection=NewCollection) and (FOwnerPersistent=NewOwnerPersistent)
|
||||||
|
and (FPropertyName=NewPropName) then
|
||||||
|
exit;
|
||||||
|
FCollection:=NewCollection;
|
||||||
|
FOwnerPersistent:=NewOwnerPersistent;
|
||||||
|
FPropertyName:=NewPropName;
|
||||||
|
//debugln('TCollectionPropertyEditorForm.SetCollection A Collection=',dbgsName(FCollection),' OwnerPersistent=',dbgsName(OwnerPersistent),' PropName=',PropertyName);
|
||||||
|
if GlobalDesignHook<>nil then begin
|
||||||
|
if FOwnerPersistent<>nil then begin
|
||||||
|
GlobalDesignHook.AddHandlerComponentRenamed(@ComponentRenamed);
|
||||||
|
GlobalDesignHook.AddHandlerPersistentDeleting(@PersistentDeleting);
|
||||||
|
end else begin
|
||||||
|
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
FillCollectionListBox;
|
||||||
|
end;
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
function TCollectionPropertyEditor.ReadElement(Index: integer): TPersistent;
|
function TCollectionPropertyEditor.ReadElement(Index: integer): TPersistent;
|
||||||
@ -3747,17 +3815,10 @@ begin
|
|||||||
TheCollection := TCollection(GetObjectValue);
|
TheCollection := TCollection(GetObjectValue);
|
||||||
if TheCollection=nil then
|
if TheCollection=nil then
|
||||||
raise Exception.Create('Collection=nil');
|
raise Exception.Create('Collection=nil');
|
||||||
If Assigned(CollectionForm) then
|
If CollectionForm=nil then
|
||||||
CollectionForm.Free;
|
CollectionForm := TCollectionPropertyEditorForm.Create(Application);
|
||||||
CollectionForm := TCollectionPropertyEditorForm.Create(Application);
|
CollectionForm.SetCollection(TheCollection,GetComponent(0),GetName);
|
||||||
with CollectionForm do begin
|
CollectionForm.Show;
|
||||||
Collection := TheCollection;
|
|
||||||
PropertyName := GetPropInfo^.Name;
|
|
||||||
PersistentName := '';
|
|
||||||
Caption := 'Editing ' + GetPropInfo^.Name;
|
|
||||||
FillCollectionListBox;
|
|
||||||
Show;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TClassPropertyEditor }
|
{ TClassPropertyEditor }
|
||||||
|
@ -674,12 +674,12 @@ type
|
|||||||
+-----+
|
+-----+
|
||||||
|
|
||||||
If you want to have the top of B the same as the top of C use
|
If you want to have the top of B the same as the top of C use
|
||||||
B.AnchorSide[akTop].Control:=C;
|
|
||||||
B.AnchorSide[akTop].Side:=asrTop;
|
B.AnchorSide[akTop].Side:=asrTop;
|
||||||
|
B.AnchorSide[akTop].Control:=C;
|
||||||
If you want to keep a distance of 10 pixels between B and C use
|
If you want to keep a distance of 10 pixels between B and C use
|
||||||
B.BorderSpacing.Right:=10;
|
B.BorderSpacing.Right:=10;
|
||||||
B.AnchorSide[akRight].Control:=C;
|
|
||||||
B.AnchorSide[akRight].Side:=asrLeft;
|
B.AnchorSide[akRight].Side:=asrLeft;
|
||||||
|
B.AnchorSide[akRight].Control:=C;
|
||||||
|
|
||||||
Do not setup in both directions, because this will create a circle, and
|
Do not setup in both directions, because this will create a circle, and
|
||||||
circles are not allowed.
|
circles are not allowed.
|
||||||
@ -692,11 +692,11 @@ type
|
|||||||
+-------+
|
+-------+
|
||||||
|
|
||||||
Centering A relative to B:
|
Centering A relative to B:
|
||||||
A.AnchorSide[akTop].Control:=B;
|
|
||||||
A.AnchorSide[akTop].Side:=arsCenter;
|
A.AnchorSide[akTop].Side:=arsCenter;
|
||||||
|
A.AnchorSide[akTop].Control:=B;
|
||||||
Or use this. It's equivalent:
|
Or use this. It's equivalent:
|
||||||
A.AnchorSide[akBottom].Control:=B;
|
|
||||||
A.AnchorSide[akBottom].Side:=arsCenter;
|
A.AnchorSide[akBottom].Side:=arsCenter;
|
||||||
|
A.AnchorSide[akBottom].Control:=B;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2853,6 +2853,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.275 2005/01/24 14:57:36 mattias
|
||||||
|
fixed TCollectionPropertyEditorForm to recognize renames and deletes
|
||||||
|
|
||||||
Revision 1.274 2005/01/24 12:23:11 mattias
|
Revision 1.274 2005/01/24 12:23:11 mattias
|
||||||
fixed TColorButton.Paint
|
fixed TColorButton.Paint
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user