mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-21 17:02:37 +02:00
IDE: designer mediator: implemented rubberband and draw markers
git-svn-id: trunk@21649 -
This commit is contained in:
parent
1417561829
commit
5a72f4fee4
@ -488,9 +488,10 @@ type
|
|||||||
|
|
||||||
procedure SelectAll(ALookupRoot: TComponent);
|
procedure SelectAll(ALookupRoot: TComponent);
|
||||||
procedure SelectWithRubberBand(ALookupRoot: TComponent;
|
procedure SelectWithRubberBand(ALookupRoot: TComponent;
|
||||||
|
AMediator: TDesignerMediator;
|
||||||
ClearBefore, ExclusiveOr: boolean;
|
ClearBefore, ExclusiveOr: boolean;
|
||||||
var SelectionChanged: boolean;
|
var SelectionChanged: boolean;
|
||||||
MaxParentControl: TControl);
|
MaxParentComponent: TComponent);
|
||||||
|
|
||||||
property Visible:boolean read GetVisible write SetVisible;
|
property Visible:boolean read GetVisible write SetVisible;
|
||||||
|
|
||||||
@ -1276,19 +1277,16 @@ procedure TControlSelection.DoDrawMarker(Index: integer;
|
|||||||
DC: TDesignerDeviceContext);
|
DC: TDesignerDeviceContext);
|
||||||
var
|
var
|
||||||
CompLeft, CompTop, CompWidth, CompHeight: integer;
|
CompLeft, CompTop, CompWidth, CompHeight: integer;
|
||||||
CompOrigin, DCOrigin: TPoint;
|
DCOrigin: TPoint;
|
||||||
CurItem: TSelectedControl;
|
CurItem: TSelectedControl;
|
||||||
AComponent: TComponent;
|
|
||||||
begin
|
begin
|
||||||
CurItem:=Items[Index];
|
CurItem:=Items[Index];
|
||||||
if not CurItem.IsTComponent then exit;
|
if not CurItem.IsTComponent then exit;
|
||||||
AComponent:=TComponent(CurItem.Persistent);
|
|
||||||
|
|
||||||
GetComponentBounds(AComponent,CompLeft,CompTop,CompWidth,CompHeight);
|
CurItem.GetFormRelativeBounds(CompLeft,CompTop,CompWidth,CompHeight);
|
||||||
CompOrigin:=GetParentFormRelativeParentClientOrigin(AComponent);
|
|
||||||
DCOrigin:=DC.FormOrigin;
|
DCOrigin:=DC.FormOrigin;
|
||||||
CompLeft:=CompLeft+CompOrigin.X-DCOrigin.X;
|
CompLeft:=CompLeft-DCOrigin.X;
|
||||||
CompTop:=CompTop+CompOrigin.Y-DCOrigin.Y;
|
CompTop:=CompTop-DCOrigin.Y;
|
||||||
|
|
||||||
{writeln('DoDrawMarker A ',FForm.Name
|
{writeln('DoDrawMarker A ',FForm.Name
|
||||||
,' Component',AComponent.Name,',',CompLeft,',',CompLeft
|
,' Component',AComponent.Name,',',CompLeft,',',CompLeft
|
||||||
@ -2480,42 +2478,65 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TControlSelection.SelectWithRubberBand(ALookupRoot: TComponent;
|
procedure TControlSelection.SelectWithRubberBand(ALookupRoot: TComponent;
|
||||||
ClearBefore, ExclusiveOr:boolean; var SelectionChanged: boolean;
|
AMediator: TDesignerMediator; ClearBefore, ExclusiveOr: boolean;
|
||||||
MaxParentControl: TControl);
|
var SelectionChanged: boolean; MaxParentComponent: TComponent);
|
||||||
var
|
var
|
||||||
i: integer;
|
i: integer;
|
||||||
AComponent: TComponent;
|
AComponent: TComponent;
|
||||||
|
|
||||||
function ControlInRubberBand(AComponent: TComponent): boolean;
|
function ComponentInRubberBand(AComponent: TComponent): boolean;
|
||||||
var
|
var
|
||||||
ALeft, ATop, ARight, ABottom: integer;
|
ALeft, ATop, ARight, ABottom: integer;
|
||||||
Origin: TPoint;
|
Origin: TPoint;
|
||||||
AControl: TControl;
|
AControl: TControl;
|
||||||
|
CurBounds: TRect;
|
||||||
|
CurParent: TComponent;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if ComponentIsInvisible(AComponent) then exit;
|
if AMediator<>nil then begin
|
||||||
if (AComponent is TControl) then begin
|
// check if component is visible on form
|
||||||
AControl:=TControl(AComponent);
|
if not AMediator.ComponentIsVisible(AComponent) then exit;
|
||||||
// check if control is visible on form
|
if MaxParentComponent<>nil then begin
|
||||||
if not ControlIsInDesignerVisible(AControl) then exit;
|
// check if component is a grand child
|
||||||
// check if control
|
CurParent:=AComponent.GetParentComponent;
|
||||||
if (MaxParentControl<>nil) then begin
|
|
||||||
// select only controls, that are childs of MaxParentControl
|
|
||||||
if (not MaxParentControl.IsParentOf(AControl)) then exit;
|
|
||||||
// check if control is a grand child
|
|
||||||
if (not EnvironmentOptions.RubberbandSelectsGrandChilds)
|
if (not EnvironmentOptions.RubberbandSelectsGrandChilds)
|
||||||
and (AControl.Parent<>MaxParentControl) then exit;
|
and (CurParent<>MaxParentComponent) then exit;
|
||||||
|
// check if component is a child (direct or grand)
|
||||||
|
while (CurParent<>nil) and (CurParent<>MaxParentComponent) do
|
||||||
|
CurParent:=CurParent.GetParentComponent;
|
||||||
|
if CurParent=nil then exit;
|
||||||
end;
|
end;
|
||||||
end;
|
AMediator.GetBounds(AComponent,CurBounds);
|
||||||
Origin:=GetParentFormRelativeTopLeft(AComponent);
|
Origin:=AMediator.GetComponentOriginOnForm(AComponent);
|
||||||
ALeft:=Origin.X;
|
ALeft:=Origin.X;
|
||||||
ATop:=Origin.Y;
|
ATop:=Origin.Y;
|
||||||
if AComponent is TControl then begin
|
ARight:=ALeft+CurBounds.Right-CurBounds.Left;
|
||||||
ARight:=ALeft+TControl(AComponent).Width;
|
ABottom:=ATop+CurBounds.Bottom-CurBounds.Top;
|
||||||
ABottom:=ATop+TControl(AComponent).Height;
|
|
||||||
end else begin
|
end else begin
|
||||||
ARight:=ALeft+NonVisualCompWidth;
|
if ComponentIsInvisible(AComponent) then exit;
|
||||||
ABottom:=ATop+NonVisualCompWidth;
|
if (AComponent is TControl) then begin
|
||||||
|
AControl:=TControl(AComponent);
|
||||||
|
// check if control is visible on form
|
||||||
|
if not ControlIsInDesignerVisible(AControl) then exit;
|
||||||
|
// check if control
|
||||||
|
if (MaxParentComponent is TWinControl) then begin
|
||||||
|
// select only controls, that are childs of MaxParentComponent
|
||||||
|
if (not TWinControl(MaxParentComponent).IsParentOf(AControl)) then exit;
|
||||||
|
// check if control is a grand child
|
||||||
|
if (not EnvironmentOptions.RubberbandSelectsGrandChilds)
|
||||||
|
and (AControl.Parent<>MaxParentComponent) then exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Origin:=GetParentFormRelativeTopLeft(AComponent);
|
||||||
|
ALeft:=Origin.X;
|
||||||
|
ATop:=Origin.Y;
|
||||||
|
if AComponent is TControl then begin
|
||||||
|
ARight:=ALeft+TControl(AComponent).Width;
|
||||||
|
ABottom:=ATop+TControl(AComponent).Height;
|
||||||
|
end else begin
|
||||||
|
ARight:=ALeft+NonVisualCompWidth;
|
||||||
|
ABottom:=ATop+NonVisualCompWidth;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
Result:=(ALeft<FRubberBandBounds.Right)
|
Result:=(ALeft<FRubberBandBounds.Right)
|
||||||
and (ATop<FRubberBandBounds.Bottom)
|
and (ATop<FRubberBandBounds.Bottom)
|
||||||
@ -2533,7 +2554,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
for i:=0 to ALookupRoot.ComponentCount-1 do begin
|
for i:=0 to ALookupRoot.ComponentCount-1 do begin
|
||||||
AComponent:=ALookupRoot.Components[i];
|
AComponent:=ALookupRoot.Components[i];
|
||||||
if not ControlInRubberBand(AComponent) then begin
|
if not ComponentInRubberBand(AComponent) then begin
|
||||||
if IsSelected(AComponent) then begin
|
if IsSelected(AComponent) then begin
|
||||||
Remove(AComponent);
|
Remove(AComponent);
|
||||||
SelectionChanged:=true;
|
SelectionChanged:=true;
|
||||||
@ -2543,7 +2564,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
for i:=0 to ALookupRoot.ComponentCount-1 do begin
|
for i:=0 to ALookupRoot.ComponentCount-1 do begin
|
||||||
AComponent:=ALookupRoot.Components[i];
|
AComponent:=ALookupRoot.Components[i];
|
||||||
if ControlInRubberBand(AComponent) then begin
|
if ComponentInRubberBand(AComponent) then begin
|
||||||
if IsSelected(AComponent) then begin
|
if IsSelected(AComponent) then begin
|
||||||
if ExclusiveOr then begin
|
if ExclusiveOr then begin
|
||||||
Remove(AComponent);
|
Remove(AComponent);
|
||||||
|
@ -1600,7 +1600,7 @@ var
|
|||||||
|
|
||||||
procedure RubberbandSelect;
|
procedure RubberbandSelect;
|
||||||
var
|
var
|
||||||
MaxParentControl: TControl;
|
MaxParentComponent: TComponent;
|
||||||
begin
|
begin
|
||||||
if (ssShift in Shift)
|
if (ssShift in Shift)
|
||||||
and (ControlSelection.SelectionForm<>nil)
|
and (ControlSelection.SelectionForm<>nil)
|
||||||
@ -1620,14 +1620,17 @@ var
|
|||||||
MoveNonVisualComponentsIntoForm;
|
MoveNonVisualComponentsIntoForm;
|
||||||
// if user press the Control key, then component candidates are only
|
// if user press the Control key, then component candidates are only
|
||||||
// childs of the control, where the mouse started
|
// childs of the control, where the mouse started
|
||||||
if (ssCtrl in shift) and (MouseDownComponent is TControl) then
|
if (ssCtrl in shift) then begin
|
||||||
MaxParentControl:=TControl(MouseDownComponent)
|
if MouseDownComponent=Form then
|
||||||
else
|
MaxParentComponent:=FLookupRoot
|
||||||
MaxParentControl:=Form;
|
else
|
||||||
|
MaxParentComponent:=MouseDownComponent;
|
||||||
|
end else
|
||||||
|
MaxParentComponent:=FLookupRoot;
|
||||||
SelectionChanged:=false;
|
SelectionChanged:=false;
|
||||||
ControlSelection.SelectWithRubberBand(
|
ControlSelection.SelectWithRubberBand(
|
||||||
FLookupRoot,NewRubberbandSelection,ssShift in Shift,SelectionChanged,
|
FLookupRoot,Mediator,NewRubberbandSelection,ssShift in Shift,
|
||||||
MaxParentControl);
|
SelectionChanged,MaxParentComponent);
|
||||||
if ControlSelection.Count=0 then begin
|
if ControlSelection.Count=0 then begin
|
||||||
ControlSelection.Add(FLookupRoot);
|
ControlSelection.Add(FLookupRoot);
|
||||||
SelectionChanged:=true;
|
SelectionChanged:=true;
|
||||||
|
@ -12,4 +12,11 @@ object MyForm1: TMyForm1
|
|||||||
Height = 25
|
Height = 25
|
||||||
Caption = 'MyButton1'
|
Caption = 'MyButton1'
|
||||||
end
|
end
|
||||||
|
object MyButton2: TMyButton
|
||||||
|
Left = 30
|
||||||
|
Top = 70
|
||||||
|
Width = 75
|
||||||
|
Height = 25
|
||||||
|
Caption = 'MyButton2'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,5 +2,6 @@ LazarusResources.Add('TMyForm1','FORMDATA',[
|
|||||||
'TPF0'#8'TMyForm1'#7'MyForm1'#4'Left'#3'?'#1#3'Top'#3#231#0#5'Width'#3'B'#1#6
|
'TPF0'#8'TMyForm1'#7'MyForm1'#4'Left'#3'?'#1#3'Top'#3#231#0#5'Width'#3'B'#1#6
|
||||||
+'Height'#3#236#0#7'Visible'#8#7'Caption'#6#7'MyForm1'#0#9'TMyButton'#9'MyBut'
|
+'Height'#3#236#0#7'Visible'#8#7'Caption'#6#7'MyForm1'#0#9'TMyButton'#9'MyBut'
|
||||||
+'ton1'#4'Left'#2#20#3'Top'#2#10#5'Width'#2'K'#6'Height'#2#25#7'Caption'#6#9
|
+'ton1'#4'Left'#2#20#3'Top'#2#10#5'Width'#2'K'#6'Height'#2#25#7'Caption'#6#9
|
||||||
+'MyButton1'#0#0#0
|
+'MyButton1'#0#0#9'TMyButton'#9'MyButton2'#4'Left'#2#30#3'Top'#2'F'#5'Width'#2
|
||||||
|
+'K'#6'Height'#2#25#7'Caption'#6#9'MyButton2'#0#0#0
|
||||||
]);
|
]);
|
||||||
|
@ -10,6 +10,7 @@ uses
|
|||||||
type
|
type
|
||||||
TMyForm1 = class(TMyForm)
|
TMyForm1 = class(TMyForm)
|
||||||
MyButton1: TMyButton;
|
MyButton1: TMyButton;
|
||||||
|
MyButton2: TMyButton;
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
public
|
public
|
||||||
|
Loading…
Reference in New Issue
Block a user