mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 23:39:08 +02:00
multiselection markers are now painted on DesignerDC
git-svn-id: trunk@5055 -
This commit is contained in:
parent
383c1ee5f1
commit
bb399170dd
@ -95,7 +95,8 @@ type
|
|||||||
|
|
||||||
TSelectedControlFlag = (
|
TSelectedControlFlag = (
|
||||||
scfParentInSelection,
|
scfParentInSelection,
|
||||||
scfChildInSelection
|
scfChildInSelection,
|
||||||
|
scfMarkersPainted
|
||||||
);
|
);
|
||||||
TSelectedControlFlags = set of TSelectedControlFlag;
|
TSelectedControlFlags = set of TSelectedControlFlag;
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ type
|
|||||||
FDesignerForm: TCustomForm;
|
FDesignerForm: TCustomForm;
|
||||||
FFlags: TSelectedControlFlags;
|
FFlags: TSelectedControlFlags;
|
||||||
FIsTControl: boolean;
|
FIsTControl: boolean;
|
||||||
|
FMarkerPaintedBounds: TRect;
|
||||||
FOldLeft: integer;
|
FOldLeft: integer;
|
||||||
FOldTop: integer;
|
FOldTop: integer;
|
||||||
FOldWidth: integer;
|
FOldWidth: integer;
|
||||||
@ -127,7 +129,6 @@ type
|
|||||||
procedure SetWidth(AWidth: integer);
|
procedure SetWidth(AWidth: integer);
|
||||||
function GetHeight: integer;
|
function GetHeight: integer;
|
||||||
procedure SetHeight(AHeight: integer);
|
procedure SetHeight(AHeight: integer);
|
||||||
procedure SetFlags(const AValue: TSelectedControlFlags);
|
|
||||||
public
|
public
|
||||||
constructor Create(AnOwner: TControlSelection; AComponent: TComponent);
|
constructor Create(AnOwner: TControlSelection; AComponent: TComponent);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -152,10 +153,11 @@ type
|
|||||||
property OldHeight:integer read FOldHeight write FOldHeight;
|
property OldHeight:integer read FOldHeight write FOldHeight;
|
||||||
property OldFormRelativeLeftTop: TPoint
|
property OldFormRelativeLeftTop: TPoint
|
||||||
read FOldFormRelativeLeftTop write FOldFormRelativeLeftTop;
|
read FOldFormRelativeLeftTop write FOldFormRelativeLeftTop;
|
||||||
property Flags: TSelectedControlFlags read FFlags write SetFlags;
|
property Flags: TSelectedControlFlags read FFlags write FFlags;
|
||||||
property UseCache: boolean read FUseCache write SetUseCache;
|
property UseCache: boolean read FUseCache write SetUseCache;
|
||||||
property IsTControl: boolean read FIsTControl;
|
property IsTControl: boolean read FIsTControl;
|
||||||
property DesignerForm: TCustomForm read FDesignerForm;
|
property DesignerForm: TCustomForm read FDesignerForm;
|
||||||
|
property MarkerPaintedBounds: TRect read FMarkerPaintedBounds write FMarkerPaintedBounds;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -310,6 +312,7 @@ type
|
|||||||
procedure DoApplyUserBounds;
|
procedure DoApplyUserBounds;
|
||||||
procedure UpdateRealBounds;
|
procedure UpdateRealBounds;
|
||||||
procedure UpdateParentChildFlags;
|
procedure UpdateParentChildFlags;
|
||||||
|
procedure DoDrawMarker(Index: integer; DC: TDesignerDeviceContext);
|
||||||
|
|
||||||
// snapping
|
// snapping
|
||||||
function CleanGridSizeX: integer;
|
function CleanGridSizeX: integer;
|
||||||
@ -409,7 +412,9 @@ type
|
|||||||
procedure DrawMarker(AComponent: TComponent; DC: TDesignerDeviceContext);
|
procedure DrawMarker(AComponent: TComponent; DC: TDesignerDeviceContext);
|
||||||
procedure DrawMarkerAt(DC: TDesignerDeviceContext;
|
procedure DrawMarkerAt(DC: TDesignerDeviceContext;
|
||||||
ALeft, ATop, AWidth, AHeight: integer);
|
ALeft, ATop, AWidth, AHeight: integer);
|
||||||
|
procedure DrawMarkers(DC: TDesignerDeviceContext);
|
||||||
property ActiveGrabber: TGrabber read FActiveGrabber write SetActiveGrabber;
|
property ActiveGrabber: TGrabber read FActiveGrabber write SetActiveGrabber;
|
||||||
|
procedure InvalidateMarkersForComponent(AComponent: TComponent);
|
||||||
|
|
||||||
// user wished bounds:
|
// user wished bounds:
|
||||||
property Left:integer read FLeft;
|
property Left:integer read FLeft;
|
||||||
@ -621,12 +626,6 @@ begin
|
|||||||
Result:=GetComponentLeft(FComponent);
|
Result:=GetComponentLeft(FComponent);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSelectedControl.SetFlags(const AValue: TSelectedControlFlags);
|
|
||||||
begin
|
|
||||||
if FFlags=AValue then exit;
|
|
||||||
FFlags:=AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSelectedControl.SetLeft(ALeft: integer);
|
procedure TSelectedControl.SetLeft(ALeft: integer);
|
||||||
begin
|
begin
|
||||||
if FIsTControl then
|
if FIsTControl then
|
||||||
@ -1065,6 +1064,33 @@ begin
|
|||||||
Exclude(FStates,cssParentChildFlagsNeedUpdate);
|
Exclude(FStates,cssParentChildFlagsNeedUpdate);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TControlSelection.DoDrawMarker(Index: integer;
|
||||||
|
DC: TDesignerDeviceContext);
|
||||||
|
var
|
||||||
|
CompLeft, CompTop, CompWidth, CompHeight: integer;
|
||||||
|
CompOrigin, DCOrigin: TPoint;
|
||||||
|
CurItem: TSelectedControl;
|
||||||
|
AComponent: TComponent;
|
||||||
|
begin
|
||||||
|
CurItem:=Items[Index];
|
||||||
|
AComponent:=CurItem.Component;
|
||||||
|
|
||||||
|
GetComponentBounds(AComponent,CompLeft,CompTop,CompWidth,CompHeight);
|
||||||
|
CompOrigin:=GetParentFormRelativeParentClientOrigin(AComponent);
|
||||||
|
DCOrigin:=DC.FormOrigin;
|
||||||
|
CompLeft:=CompLeft+CompOrigin.X-DCOrigin.X;
|
||||||
|
CompTop:=CompTop+CompOrigin.Y-DCOrigin.Y;
|
||||||
|
|
||||||
|
{writeln('DoDrawMarker A ',FForm.Name
|
||||||
|
,' Component',AComponent.Name,',',CompLeft,',',CompLeft
|
||||||
|
,' DCOrigin=',DCOrigin.X,',',DCOrigin.Y
|
||||||
|
);}
|
||||||
|
|
||||||
|
DrawMarkerAt(DC,CompLeft,CompTop,CompWidth,CompHeight);
|
||||||
|
CurItem.Flags:=CurItem.Flags+[scfMarkersPainted];
|
||||||
|
CurItem.MarkerPaintedBounds:=Bounds(CompLeft,CompTop,CompWidth,CompHeight);
|
||||||
|
end;
|
||||||
|
|
||||||
function TControlSelection.CleanGridSizeX: integer;
|
function TControlSelection.CleanGridSizeX: integer;
|
||||||
begin
|
begin
|
||||||
Result:=EnvironmentOptions.GridSizeX;
|
Result:=EnvironmentOptions.GridSizeX;
|
||||||
@ -2038,30 +2064,72 @@ begin
|
|||||||
DC.Canvas.Brush.Color:=OldBrushColor;
|
DC.Canvas.Brush.Color:=OldBrushColor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TControlSelection.DrawMarkers(DC: TDesignerDeviceContext);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
AComponent: TComponent;
|
||||||
|
begin
|
||||||
|
if (Count<2) or (FForm=nil) then exit;
|
||||||
|
for i:=0 to Count-1 do begin
|
||||||
|
AComponent:=Items[i].Component;
|
||||||
|
if (AComponent=FLookupRoot)
|
||||||
|
or ComponentIsInvisible(AComponent) then continue;
|
||||||
|
DoDrawMarker(i,DC);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TControlSelection.InvalidateMarkersForComponent(AComponent: TComponent
|
||||||
|
);
|
||||||
|
|
||||||
|
procedure InvalidateMarker(x,y: integer);
|
||||||
|
var
|
||||||
|
R: TRect;
|
||||||
|
begin
|
||||||
|
R:=Rect(x,y,x+MarkerSize,y+MarkerSize);
|
||||||
|
InvalidateRect(FForm.Handle,@R,true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
CurItem: TSelectedControl;
|
||||||
|
ComponentBounds: TRect;
|
||||||
|
LeftMarker: Integer;
|
||||||
|
TopMarker: Integer;
|
||||||
|
RightMarker: Integer;
|
||||||
|
BottomMarker: Integer;
|
||||||
|
begin
|
||||||
|
if (FForm=nil) then exit;
|
||||||
|
i:=IndexOf(AComponent);
|
||||||
|
if (i>=0) then begin
|
||||||
|
CurItem:=Items[i];
|
||||||
|
if scfMarkersPainted in CurItem.Flags then begin
|
||||||
|
ComponentBounds:=CurItem.MarkerPaintedBounds;
|
||||||
|
LeftMarker:=ComponentBounds.Left;
|
||||||
|
TopMarker:=ComponentBounds.Top;
|
||||||
|
RightMarker:=ComponentBounds.Right-MarkerSize;
|
||||||
|
BottomMarker:=ComponentBounds.Bottom-MarkerSize;
|
||||||
|
InvalidateMarker(LeftMarker,TopMarker);
|
||||||
|
InvalidateMarker(LeftMarker,BottomMarker);
|
||||||
|
InvalidateMarker(RightMarker,TopMarker);
|
||||||
|
InvalidateMarker(RightMarker,BottomMarker);
|
||||||
|
CurItem.Flags:=CurItem.Flags-[scfMarkersPainted];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TControlSelection.DrawMarker(AComponent: TComponent;
|
procedure TControlSelection.DrawMarker(AComponent: TComponent;
|
||||||
DC: TDesignerDeviceContext);
|
DC: TDesignerDeviceContext);
|
||||||
var
|
var
|
||||||
CompLeft, CompTop, CompWidth, CompHeight: integer;
|
i: Integer;
|
||||||
CompOrigin, DCOrigin: TPoint;
|
|
||||||
begin
|
begin
|
||||||
if (Count<2)
|
if (Count<2)
|
||||||
or (FForm=nil)
|
or (FForm=nil)
|
||||||
or (AComponent=FLookupRoot)
|
or (AComponent=FLookupRoot) then exit;
|
||||||
or (not IsSelected(AComponent))
|
i:=IndexOf(AComponent);
|
||||||
or ComponentIsInvisible(AComponent) then exit;
|
if i<0 then exit;
|
||||||
|
if ComponentIsInvisible(AComponent) then exit;
|
||||||
|
|
||||||
GetComponentBounds(AComponent,CompLeft,CompTop,CompWidth,CompHeight);
|
DoDrawMarker(i,DC);
|
||||||
CompOrigin:=GetParentFormRelativeParentClientOrigin(AComponent);
|
|
||||||
DCOrigin:=DC.FormOrigin;
|
|
||||||
CompLeft:=CompLeft+CompOrigin.X-DCOrigin.X;
|
|
||||||
CompTop:=CompTop+CompOrigin.Y-DCOrigin.Y;
|
|
||||||
|
|
||||||
{writeln('DrawMarker A ',FForm.Name
|
|
||||||
,' Component',AComponent.Name,',',CompLeft,',',CompLeft
|
|
||||||
,' DCOrigin=',DCOrigin.X,',',DCOrigin.Y
|
|
||||||
);}
|
|
||||||
|
|
||||||
DrawMarkerAt(DC,CompLeft,CompTop,CompWidth,CompHeight);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TControlSelection.DrawRubberband(DC: TDesignerDeviceContext);
|
procedure TControlSelection.DrawRubberband(DC: TDesignerDeviceContext);
|
||||||
|
@ -916,18 +916,10 @@ begin
|
|||||||
PaintClientGrid(TWinControl(Sender),DDC);
|
PaintClientGrid(TWinControl(Sender),DDC);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// marker (multi selection markers)
|
|
||||||
if (ControlSelection.SelectionForm=Form)
|
|
||||||
and (ControlSelection.IsSelected(Sender)) then begin
|
|
||||||
ControlSelection.DrawMarker(Sender,DDC);
|
|
||||||
end;
|
|
||||||
//writeln('TDesigner.PaintControl NOT Drawing items');
|
|
||||||
//DoPaintDesignerItems;
|
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
DDC.Clear;
|
DDC.Clear;
|
||||||
end;
|
end;
|
||||||
//writeln('TDesigner.PaintControl END ',Sender.Name);
|
//writeln('TDesigner.PaintControl END ',Sender.Name);
|
||||||
|
|
||||||
if not OldDuringPaintControl then
|
if not OldDuringPaintControl then
|
||||||
Exclude(FFlags,dfDuringPaintControl);
|
Exclude(FFlags,dfDuringPaintControl);
|
||||||
@ -948,6 +940,7 @@ begin
|
|||||||
FOnPropertiesChanged(Self);
|
FOnPropertiesChanged(Self);
|
||||||
end;
|
end;
|
||||||
ControlSelection.InvalidateGuideLinesCache;
|
ControlSelection.InvalidateGuideLinesCache;
|
||||||
|
ControlSelection.InvalidateMarkersForComponent(Sender);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -964,6 +957,7 @@ begin
|
|||||||
FOnPropertiesChanged(Self);
|
FOnPropertiesChanged(Self);
|
||||||
end;
|
end;
|
||||||
ControlSelection.InvalidateGuideLinesCache;
|
ControlSelection.InvalidateGuideLinesCache;
|
||||||
|
ControlSelection.InvalidateMarkersForComponent(Sender);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2061,8 +2055,9 @@ end;
|
|||||||
procedure TDesigner.DoPaintDesignerItems;
|
procedure TDesigner.DoPaintDesignerItems;
|
||||||
begin
|
begin
|
||||||
// marker (multi selection markers)
|
// marker (multi selection markers)
|
||||||
if (ControlSelection.SelectionForm=Form) then begin
|
if (ControlSelection.SelectionForm=Form)
|
||||||
// ToDo: draw all markers
|
and (ControlSelection.Count>1) then begin
|
||||||
|
ControlSelection.DrawMarkers(DDC);
|
||||||
end;
|
end;
|
||||||
// non visual component icons
|
// non visual component icons
|
||||||
DrawNonVisualComponents(DDC);
|
DrawNonVisualComponents(DDC);
|
||||||
|
Loading…
Reference in New Issue
Block a user