mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 18:39:09 +02:00
MG: loading forms now creates all TComponentInterfaces, fixed removing components
git-svn-id: trunk@1939 -
This commit is contained in:
parent
8831ae73d0
commit
65c40892a9
@ -118,6 +118,7 @@ type
|
|||||||
Procedure KeyDown(Sender: TControl; TheMessage:TLMKEY);
|
Procedure KeyDown(Sender: TControl; TheMessage:TLMKEY);
|
||||||
Procedure KeyUp(Sender: TControl; TheMessage:TLMKEY);
|
Procedure KeyUp(Sender: TControl; TheMessage:TLMKEY);
|
||||||
|
|
||||||
|
procedure DoDeleteSelectedComponents;
|
||||||
Procedure RemoveControl(Control: TComponent);
|
Procedure RemoveControl(Control: TComponent);
|
||||||
Procedure NudgeControl(DiffX, DiffY: Integer);
|
Procedure NudgeControl(DiffX, DiffY: Integer);
|
||||||
Procedure NudgeSize(DiffX, DiffY: Integer);
|
Procedure NudgeSize(DiffX, DiffY: Integer);
|
||||||
@ -230,8 +231,8 @@ Begin
|
|||||||
Writeln('[TDesigner.RemoveControl] ',Control.Name,':',Control.ClassName);
|
Writeln('[TDesigner.RemoveControl] ',Control.Name,':',Control.ClassName);
|
||||||
if Assigned(FOnRemoveComponent) then
|
if Assigned(FOnRemoveComponent) then
|
||||||
FOnRemoveComponent(Self,Control);
|
FOnRemoveComponent(Self,Control);
|
||||||
FCustomForm.RemoveControl(TCOntrol(Control));
|
//FCustomForm.RemoveControl(TControl(Control));
|
||||||
//this send a message to notification and removes it from the controlselection
|
// this sends a message to notification and removes it from the controlselection
|
||||||
FFormEditor.DeleteControl(Control);
|
FFormEditor.DeleteControl(Control);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -543,14 +544,14 @@ Begin
|
|||||||
NewCI := TComponentInterface(FFormEditor.CreateComponent(
|
NewCI := TComponentInterface(FFormEditor.CreateComponent(
|
||||||
ParentCI,SelectedCompClass.ComponentClass
|
ParentCI,SelectedCompClass.ComponentClass
|
||||||
,NewLeft,NewTop,NewWidth,NewHeight));
|
,NewLeft,NewTop,NewWidth,NewHeight));
|
||||||
if NewCI.Control is TControl then
|
if NewCI.Component is TControl then
|
||||||
TControl(NewCI.Control).Visible:=true;
|
TControl(NewCI.Component).Visible:=true;
|
||||||
if Assigned(FOnSetDesigning) then
|
if Assigned(FOnSetDesigning) then
|
||||||
FOnSetDesigning(Self,NewCI.Control,True);
|
FOnSetDesigning(Self,NewCI.Component,True);
|
||||||
if Assigned(FOnAddComponent) then
|
if Assigned(FOnAddComponent) then
|
||||||
FOnAddComponent(Self,NewCI.Control,SelectedCompClass);
|
FOnAddComponent(Self,NewCI.Component,SelectedCompClass);
|
||||||
|
|
||||||
SelectOnlyThisComponent(TComponent(NewCI.Control));
|
SelectOnlyThisComponent(TComponent(NewCI.Component));
|
||||||
if not (ssShift in Shift) then
|
if not (ssShift in Shift) then
|
||||||
if Assigned(FOnUnselectComponentClass) then
|
if Assigned(FOnUnselectComponentClass) then
|
||||||
// this resets the component palette to the selection tool
|
// this resets the component palette to the selection tool
|
||||||
@ -558,7 +559,7 @@ Begin
|
|||||||
Form.Invalidate;
|
Form.Invalidate;
|
||||||
{$IFDEF VerboseDesigner}
|
{$IFDEF VerboseDesigner}
|
||||||
writeln('NEW COMPONENT ADDED: Form.ComponentCount=',Form.ComponentCount,
|
writeln('NEW COMPONENT ADDED: Form.ComponentCount=',Form.ComponentCount,
|
||||||
' NewCI.Control.Owner.Name=',NewCI.Control.Owner.Name);
|
' NewCI.Control.Owner.Name=',NewCI.Component.Owner.Name);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
ControlSelection.EndUpdate;
|
ControlSelection.EndUpdate;
|
||||||
@ -666,7 +667,6 @@ end;
|
|||||||
}
|
}
|
||||||
Procedure TDesigner.KeyDown(Sender : TControl; TheMessage:TLMKEY);
|
Procedure TDesigner.KeyDown(Sender : TControl; TheMessage:TLMKEY);
|
||||||
var
|
var
|
||||||
I : Integer;
|
|
||||||
Shift : TShiftState;
|
Shift : TShiftState;
|
||||||
Begin
|
Begin
|
||||||
{$IFDEF VerboseDesigner}
|
{$IFDEF VerboseDesigner}
|
||||||
@ -682,16 +682,7 @@ Begin
|
|||||||
|
|
||||||
if (TheMessage.CharCode = 46) then //DEL KEY
|
if (TheMessage.CharCode = 46) then //DEL KEY
|
||||||
begin
|
begin
|
||||||
if (ControlSelection.Count = 1)
|
DoDeleteSelectedComponents;
|
||||||
and (ControlSelection.Items[0].Component = FCustomForm) then
|
|
||||||
Exit;
|
|
||||||
ControlSelection.BeginUpdate;
|
|
||||||
for I := ControlSelection.Count-1 downto 0 do Begin
|
|
||||||
Writeln('I = '+inttostr(i));
|
|
||||||
RemoveControl(ControlSelection.Items[I].Component);
|
|
||||||
End;
|
|
||||||
SelectOnlythisComponent(FCustomForm);
|
|
||||||
ControlSelection.EndUpdate;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if TheMessage.CharCode = 38 then //UP ARROW
|
if TheMessage.CharCode = 38 then //UP ARROW
|
||||||
@ -740,6 +731,26 @@ Begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDesigner.DoDeleteSelectedComponents;
|
||||||
|
var
|
||||||
|
AComponent: TComponent;
|
||||||
|
begin
|
||||||
|
if (ControlSelection.Count = 1)
|
||||||
|
and (ControlSelection.Items[0].Component = FCustomForm) then
|
||||||
|
Exit;
|
||||||
|
ControlSelection.BeginUpdate;
|
||||||
|
while ControlSelection.Count>0 do Begin
|
||||||
|
AComponent:=ControlSelection[ControlSelection.Count-1].Component;
|
||||||
|
{$IFDEF VerboseDesigner}
|
||||||
|
Writeln('TDesigner: Removing control: ',
|
||||||
|
AComponent.Name,':',AComponent.ClassName);
|
||||||
|
{$ENDIF}
|
||||||
|
RemoveControl(AComponent);
|
||||||
|
End;
|
||||||
|
SelectOnlythisComponent(FCustomForm);
|
||||||
|
ControlSelection.EndUpdate;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDesigner.IsDesignMsg(Sender: TControl; var TheMessage: TLMessage): Boolean;
|
function TDesigner.IsDesignMsg(Sender: TControl; var TheMessage: TLMessage): Boolean;
|
||||||
Begin
|
Begin
|
||||||
Result := false;
|
Result := false;
|
||||||
@ -772,17 +783,17 @@ end;
|
|||||||
|
|
||||||
procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
|
procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
|
||||||
Begin
|
Begin
|
||||||
if Operation = opInsert then
|
if Operation = opInsert then begin
|
||||||
begin
|
{$IFDEF VerboseDesigner}
|
||||||
Writeln('opInsert');
|
Writeln('opInsert');
|
||||||
|
{$ENDIF}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Operation = opRemove then
|
if Operation = opRemove then begin
|
||||||
begin
|
{$IFDEF VerboseDesigner}
|
||||||
writeln('[TDesigner.Notification] opRemove '+
|
writeln('[TDesigner.Notification] opRemove ',
|
||||||
''''+AComponent.ClassName+'.'+AComponent.Name+'''');
|
AComponent.Name,':',AComponent.ClassName);
|
||||||
if (AComponent is TControl) then
|
{$ENDIF}
|
||||||
if ControlSelection.IsSelected(AComponent) then
|
|
||||||
ControlSelection.Remove(AComponent);
|
ControlSelection.Remove(AComponent);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user