MG: added some multi form editing checks

git-svn-id: trunk@2099 -
This commit is contained in:
lazarus 2002-08-17 23:40:56 +00:00
parent 3d9c75633e
commit d6391459c5

View File

@ -317,6 +317,8 @@ Begin
{$IFDEF VerboseDesigner} {$IFDEF VerboseDesigner}
Writeln('[TDesigner.NudgeControl]'); Writeln('[TDesigner.NudgeControl]');
{$ENDIF} {$ENDIF}
if (ControlSelection.SelectionForm<>Form)
or (ControlSelection.IsSelected(Form)) then exit;
ControlSelection.MoveSelection(DiffX, DiffY); ControlSelection.MoveSelection(DiffX, DiffY);
if ControlSelection.OnlyNonVisualComponentsSelected then if ControlSelection.OnlyNonVisualComponentsSelected then
FCustomForm.Invalidate; FCustomForm.Invalidate;
@ -327,6 +329,8 @@ Begin
{$IFDEF VerboseDesigner} {$IFDEF VerboseDesigner}
Writeln('[TDesigner.NudgeSize]'); Writeln('[TDesigner.NudgeSize]');
{$ENDIF} {$ENDIF}
if (ControlSelection.SelectionForm<>Form)
or (ControlSelection.IsSelected(Form)) then exit;
ControlSelection.SizeSelection(DiffX, DiffY); ControlSelection.SizeSelection(DiffX, DiffY);
end; end;
@ -522,9 +526,9 @@ Begin
writeln('************************************************************'); writeln('************************************************************');
write('MouseDownOnControl'); write('MouseDownOnControl');
write(' ',Sender.Name,':',Sender.ClassName); write(' ',Sender.Name,':',Sender.ClassName);
write(' Msg=',TheMessage.Pos.X,',',TheMessage.Pos.Y); //write(' Msg=',TheMessage.Pos.X,',',TheMessage.Pos.Y);
write(' Mouse=',MouseDownPos.X,',',MouseDownPos.Y); //write(' Mouse=',MouseDownPos.X,',',MouseDownPos.Y);
writeln(''); //writeln('');
if (TheMessage.Keys and MK_Shift) = MK_Shift then if (TheMessage.Keys and MK_Shift) = MK_Shift then
Write(' Shift down') Write(' Shift down')
@ -613,7 +617,7 @@ procedure TDesigner.MouseUpOnControl(Sender : TControl;
TheMessage:TLMMouse); TheMessage:TLMMouse);
var var
ParentCI, NewCI: TComponentInterface; ParentCI, NewCI: TComponentInterface;
NewLeft, NewTop, NewWidth, NewHeight, MoveX, MoveY: Integer; NewLeft, NewTop, NewWidth, NewHeight: Integer;
Shift: TShiftState; Shift: TShiftState;
SenderParentForm: TCustomForm; SenderParentForm: TCustomForm;
RubberBandWasActive: boolean; RubberBandWasActive: boolean;
@ -648,8 +652,7 @@ var
begin begin
// add a new component // add a new component
ControlSelection.RubberbandActive:=false; ControlSelection.RubberbandActive:=false;
ControlSelection.BeginUpdate; ControlSelection.Clear;
try
// find a parent for the new component // find a parent for the new component
NewParent:=TWinControl(MouseDownComponent); NewParent:=TWinControl(MouseDownComponent);
@ -691,8 +694,13 @@ var
FOnSetDesigning(Self,NewCI.Component,True); FOnSetDesigning(Self,NewCI.Component,True);
// tell IDE about the new component (e.g. add it to the source) // tell IDE about the new component (e.g. add it to the source)
try
if Assigned(FOnComponentAdded) then if Assigned(FOnComponentAdded) then
FOnComponentAdded(Self,NewCI.Component,SelectedCompClass); FOnComponentAdded(Self,NewCI.Component,SelectedCompClass);
except
on E: Exception do
MessageDlg('Error:',E.Message,mtError,[mbOk],0);
end;
// creation completed // creation completed
// -> select new component // -> select new component
@ -707,14 +715,10 @@ var
writeln('NEW COMPONENT ADDED: Form.ComponentCount=',Form.ComponentCount, writeln('NEW COMPONENT ADDED: Form.ComponentCount=',Form.ComponentCount,
' NewCI.Control.Owner.Name=',NewCI.Component.Owner.Name); ' NewCI.Control.Owner.Name=',NewCI.Component.Owner.Name);
{$ENDIF} {$ENDIF}
finally
ControlSelection.EndUpdate;
end;
end; end;
procedure RubberbandSelect; procedure RubberbandSelect;
begin begin
ControlSelection.BeginUpdate;
if (ssShift in Shift) if (ssShift in Shift)
and (ControlSelection.SelectionForm<>nil) and (ControlSelection.SelectionForm<>nil)
and (ControlSelection.SelectionForm<>Form) and (ControlSelection.SelectionForm<>Form)
@ -725,8 +729,12 @@ var
exit; exit;
end; end;
NewRubberbandSelection:=(not (ssShift in Shift)) ControlSelection.BeginUpdate;
and ControlSelection.IsOnlySelected(Form); NewRubberbandSelection:=
((not (ssShift in Shift))
and ControlSelection.IsOnlySelected(Form))
or ((ControlSelection.SelectionForm<>nil)
and (ControlSelection.SelectionForm<>Form));
SelectionChanged:=false; SelectionChanged:=false;
ControlSelection.SelectWithRubberBand( ControlSelection.SelectWithRubberBand(
Form,NewRubberbandSelection,ssShift in Shift,SelectionChanged); Form,NewRubberbandSelection,ssShift in Shift,SelectionChanged);
@ -749,7 +757,8 @@ var
// select only the mouse down component // select only the mouse down component
if ControlSelection.AssignComponent(MouseDownComponent) then if ControlSelection.AssignComponent(MouseDownComponent) then
Form.Invalidate; Form.Invalidate;
if MouseDownClickCount=2 then begin if (MouseDownClickCount=2)
and (ControlSelection.SelectionForm=Form) then begin
// Double Click -> invoke 'Edit' of the component editor // Double Click -> invoke 'Edit' of the component editor
FShiftState:=Shift; FShiftState:=Shift;
InvokeComponentEditor(MouseDownComponent,-1); InvokeComponentEditor(MouseDownComponent,-1);
@ -788,8 +797,6 @@ Begin
GetShift; GetShift;
MouseUpPos:=GetFormRelativeMousePosition(Form); MouseUpPos:=GetFormRelativeMousePosition(Form);
MoveX:=MouseUpPos.X-MouseDownPos.X;
MoveY:=MouseUpPos.Y-MouseDownPos.Y;
SelectedCompClass:=GetSelectedComponentClass; SelectedCompClass:=GetSelectedComponentClass;
@ -797,8 +804,7 @@ Begin
writeln('************************************************************'); writeln('************************************************************');
write('MouseUpOnControl'); write('MouseUpOnControl');
write(' ',Sender.Name,':',Sender.ClassName); write(' ',Sender.Name,':',Sender.ClassName);
write(' Msg=',TheMessage.Pos.X,',',TheMessage.Pos.Y); //write(' Msg=',TheMessage.Pos.X,',',TheMessage.Pos.Y);
write(' Move=',MoveX,',',MoveY);
writeln(''); writeln('');
{$ENDIF} {$ENDIF}
@ -869,7 +875,12 @@ begin
if (OldMouseMovePos.X=LastMouseMovePos.X) if (OldMouseMovePos.X=LastMouseMovePos.X)
and (OldMouseMovePos.Y=LastMouseMovePos.Y) then exit; and (OldMouseMovePos.Y=LastMouseMovePos.Y) then exit;
Grabber:= ControlSelection.GrabberAtPos(LastMouseMovePos.X, LastMouseMovePos.Y); if ControlSelection.SelectionForm=Form then
Grabber:=ControlSelection.GrabberAtPos(
LastMouseMovePos.X, LastMouseMovePos.Y)
else
Grabber:=nil;
if MouseDownComponent=nil then begin if MouseDownComponent=nil then begin
if Grabber = nil then if Grabber = nil then
ACursor:= crDefault ACursor:= crDefault
@ -890,9 +901,10 @@ begin
if (TheMessage.keys and MK_Control) = MK_Control then if (TheMessage.keys and MK_Control) = MK_Control then
Shift := Shift + [ssCTRL]; Shift := Shift + [ssCTRL];
if ControlSelection.SelectionForm=Form then begin
if (TheMessage.keys and MK_LButton) = MK_LButton then begin if (TheMessage.keys and MK_LButton) = MK_LButton then begin
// left button pressed // left button pressed
if ControlSelection.ActiveGrabber<>nil then begin if (ControlSelection.ActiveGrabber<>nil) then begin
// grabber moving -> size selection // grabber moving -> size selection
if not (dfHasSized in FFlags) then begin if not (dfHasSized in FFlags) then begin
ControlSelection.SaveBounds; ControlSelection.SaveBounds;
@ -930,10 +942,12 @@ begin
SenderParentForm.Invalidate; SenderParentForm.Invalidate;
end; end;
end; end;
end else begin end
else begin
ControlSelection.ActiveGrabber:=nil; ControlSelection.ActiveGrabber:=nil;
end; end;
end; end;
end;
{ {
@ -999,7 +1013,7 @@ end;
Procedure TDesigner.KeyUp(Sender : TControl; TheMessage:TLMKEY); Procedure TDesigner.KeyUp(Sender : TControl; TheMessage:TLMKEY);
Begin Begin
{$IFDEF VerboseDesigner} {$IFDEF VerboseDesigner}
Writeln('TDesigner.KEYUP ',TheMessage.CharCode,' ',TheMessage.KeyData); //Writeln('TDesigner.KEYUP ',TheMessage.CharCode,' ',TheMessage.KeyData);
{$ENDIF} {$ENDIF}
end; end;
@ -1007,6 +1021,8 @@ procedure TDesigner.DoDeleteSelectedComponents;
var var
i: integer; i: integer;
begin begin
if (ControlSelection.Count=0) or (ControlSelection.SelectionForm<>Form) then
exit;
if (ControlSelection.IsSelected(FCustomForm)) then begin if (ControlSelection.IsSelected(FCustomForm)) then begin
if ControlSelection.Count>1 then if ControlSelection.Count>1 then
MessageDlg('Invalid delete', MessageDlg('Invalid delete',
@ -1365,7 +1381,8 @@ end;
function TDesigner.GetComponentEditorForSelection: TBaseComponentEditor; function TDesigner.GetComponentEditorForSelection: TBaseComponentEditor;
begin begin
Result:=nil; Result:=nil;
if ControlSelection.Count<>1 then exit; if (ControlSelection.Count<>1)
or (ControlSelection.SelectionForm<>Form) then exit;
Result:=TheFormEditor.GetComponentEditor(ControlSelection[0].Component); Result:=TheFormEditor.GetComponentEditor(ControlSelection[0].Component);
end; end;
@ -1433,7 +1450,8 @@ var
begin begin
if FPopupMenu<>nil then FPopupMenu.Free; if FPopupMenu<>nil then FPopupMenu.Free;
ControlSelIsNotEmpty:=ControlSelection.Count>0; ControlSelIsNotEmpty:=(ControlSelection.Count>0)
and (ControlSelection.SelectionForm=Form);
FormIsSelected:=ControlSelection.IsSelected(Form); FormIsSelected:=ControlSelection.IsSelected(Form);
OnlyNonVisualCompsAreSelected:= OnlyNonVisualCompsAreSelected:=
ControlSelection.OnlyNonVisualComponentsSelected; ControlSelection.OnlyNonVisualComponentsSelected;