fixed TCollectionPropertyEditorForm to recognize renames and deletes

git-svn-id: trunk@6677 -
This commit is contained in:
mattias 2005-01-24 14:57:36 +00:00
parent b2b2743b38
commit 481bc1c1e4
3 changed files with 90 additions and 26 deletions

View File

@ -1255,7 +1255,7 @@ begin
Result:=MergeSearchPaths(CurrentPath,InheritedPath);
{$IFDEF VerbosePkgUnitPath}
if Option=pcosUnitPath then
debugln('TBaseCompilerOptions.GetParsedPath Total ',dbgsName(Self),' CurrentPath="',CurrentPath,'"');
debugln('TBaseCompilerOptions.GetParsedPath Total ',dbgsName(Self),' Result="',Result,'"');
{$ENDIF}
end;

View File

@ -2450,8 +2450,15 @@ begin
end;
procedure TPropertyEditor.Initialize;
procedure RaiseNoInstance;
begin
raise Exception.Create('TPropertyEditor.Initialize '+dbgsName(Self));
end;
begin
//
if FPropList^[0].Instance=nil then
RaiseNoInstance;
end;
procedure TPropertyEditor.Modified;
@ -3425,15 +3432,20 @@ begin
SaveElements;
end;
{ TCollectionPropertyEditor }
Type
{ TCollectionPropertyEditor }
TCollectionPropertyEditorForm = class(TForm)
procedure ListClick(Sender: TObject);
procedure AddClick(Sender: TObject);
procedure DeleteClick(Sender: TObject);
procedure MoveDownButtonClick(Sender: TObject);
procedure MoveUpButtonClick(Sender: TObject);
private
FCollection: TCollection;
FOwnerPersistent: TPersistent;
FPropertyName: string;
protected
CollectionListBox: TListBox;
ButtonPanel: TPanel;
@ -3443,13 +3455,19 @@ Type
MoveDownButton: TSpeedButton;
procedure UpdateCaption;
procedure UpdateButtons;
procedure ComponentRenamed(AComponent: TComponent);
procedure PersistentDeleting(APersistent: TPersistent);
public
Collection: TCollection;
PersistentName: string;
PropertyName: string;
procedure FillCollectionListBox;
Constructor Create(TheOwner: TComponent); Override;
constructor Create(TheOwner: TComponent); Override;
destructor Destroy; override;
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;
const
@ -3537,12 +3555,19 @@ procedure TCollectionPropertyEditorForm.UpdateCaption;
var
NewCaption: String;
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]"
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
NewCaption := NewCaption + '[' +
IntToStr(CollectionListBox.ItemIndex) + ']';
NewCaption:=NewCaption + '[' + IntToStr(CollectionListBox.ItemIndex) + ']';
Caption:=NewCaption;
end;
@ -3556,6 +3581,20 @@ begin
MoveDownButton.Enabled:=(i>=0) and (i<Collection.Count-1);
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;
var
I : Longint;
@ -3658,6 +3697,13 @@ begin
end;
end;
destructor TCollectionPropertyEditorForm.Destroy;
begin
if GlobalDesignHook<>nil then
GlobalDesignHook.RemoveAllHandlersForObject(Self);
inherited Destroy;
end;
procedure TCollectionPropertyEditorForm.SelectInObjectInspector(
UnselectAll: boolean);
var
@ -3678,6 +3724,28 @@ begin
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;
@ -3747,17 +3815,10 @@ begin
TheCollection := TCollection(GetObjectValue);
if TheCollection=nil then
raise Exception.Create('Collection=nil');
If Assigned(CollectionForm) then
CollectionForm.Free;
CollectionForm := TCollectionPropertyEditorForm.Create(Application);
with CollectionForm do begin
Collection := TheCollection;
PropertyName := GetPropInfo^.Name;
PersistentName := '';
Caption := 'Editing ' + GetPropInfo^.Name;
FillCollectionListBox;
Show;
end;
If CollectionForm=nil then
CollectionForm := TCollectionPropertyEditorForm.Create(Application);
CollectionForm.SetCollection(TheCollection,GetComponent(0),GetName);
CollectionForm.Show;
end;
{ TClassPropertyEditor }

View File

@ -674,12 +674,12 @@ type
+-----+
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].Control:=C;
If you want to keep a distance of 10 pixels between B and C use
B.BorderSpacing.Right:=10;
B.AnchorSide[akRight].Control:=C;
B.AnchorSide[akRight].Side:=asrLeft;
B.AnchorSide[akRight].Control:=C;
Do not setup in both directions, because this will create a circle, and
circles are not allowed.
@ -692,11 +692,11 @@ type
+-------+
Centering A relative to B:
A.AnchorSide[akTop].Control:=B;
A.AnchorSide[akTop].Side:=arsCenter;
A.AnchorSide[akTop].Control:=B;
Or use this. It's equivalent:
A.AnchorSide[akBottom].Control:=B;
A.AnchorSide[akBottom].Side:=arsCenter;
A.AnchorSide[akBottom].Control:=B;
}
@ -2853,6 +2853,9 @@ end.
{ =============================================================================
$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
fixed TColorButton.Paint