mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-13 10:29:24 +02:00
Designer can now handle TPersistent selections, TCollectionPropertyEditor basically working
git-svn-id: trunk@5702 -
This commit is contained in:
parent
d6b764fae2
commit
84dd820d72
@ -39,8 +39,6 @@ uses
|
||||
Buttons, AVGLvlTree, LazarusIDEStrConsts, ComponentReg;
|
||||
|
||||
type
|
||||
TPersistentClass = class of TPersistent;
|
||||
|
||||
TChangeClassDlg = class(TForm)
|
||||
NewClassComboBox: TComboBox;
|
||||
NewAncestorGroupBox: TGroupBox;
|
||||
|
@ -102,22 +102,25 @@ type
|
||||
|
||||
TSelectedControl = class
|
||||
private
|
||||
FCachedFormRelativeLeftTop: TPoint;
|
||||
FCachedHeight: integer;
|
||||
FCachedLeft: integer;
|
||||
FCachedTop: integer;
|
||||
FCachedWidth: integer;
|
||||
FCachedHeight: integer;
|
||||
FCachedFormRelativeLeftTop: TPoint;
|
||||
FComponent: TComponent;
|
||||
FDesignerForm: TCustomForm;
|
||||
FFlags: TSelectedControlFlags;
|
||||
FIsNonVisualComponent: boolean;
|
||||
FIsTComponent: boolean;
|
||||
FIsTControl: boolean;
|
||||
FIsTWinControl: boolean;
|
||||
FMarkerPaintedBounds: TRect;
|
||||
FOldFormRelativeLeftTop: TPoint;
|
||||
FOldHeight: integer;
|
||||
FOldLeft: integer;
|
||||
FOldTop: integer;
|
||||
FOldWidth: integer;
|
||||
FOldHeight: integer;
|
||||
FOldFormRelativeLeftTop: TPoint;
|
||||
FOwner: TControlSelection;
|
||||
FPersistent: TPersistent;
|
||||
FUseCache: boolean;
|
||||
function GetLeft: integer;
|
||||
procedure SetLeft(ALeft: integer);
|
||||
@ -130,18 +133,19 @@ type
|
||||
function GetHeight: integer;
|
||||
procedure SetHeight(AHeight: integer);
|
||||
public
|
||||
constructor Create(AnOwner: TControlSelection; AComponent: TComponent);
|
||||
constructor Create(AnOwner: TControlSelection; APersistent: TPersistent);
|
||||
destructor Destroy; override;
|
||||
procedure SetBounds(ALeft, ATop, AWidth, AHeight: integer);
|
||||
procedure SetFormRelativeBounds(ALeft, ATop, AWidth, AHeight: integer);
|
||||
procedure GetFormRelativeBounds(var ALeft, ATop, AWidth, AHeight: integer);
|
||||
procedure SaveBounds;
|
||||
procedure UpdateCache;
|
||||
function IsTopLvl: boolean;
|
||||
function ChildInSelection: boolean;
|
||||
function ParentInSelection: boolean;
|
||||
procedure InvalidateNonVisualComponent;
|
||||
procedure InvalidateNonVisualPersistent;
|
||||
|
||||
property Component: TComponent read FComponent;
|
||||
property Persistent: TPersistent read FPersistent;
|
||||
property Owner: TControlSelection read FOwner write SetOwner;
|
||||
property Left: integer read GetLeft write SetLeft;
|
||||
property Top: integer read GetTop write SetTop;
|
||||
@ -155,7 +159,10 @@ type
|
||||
read FOldFormRelativeLeftTop write FOldFormRelativeLeftTop;
|
||||
property Flags: TSelectedControlFlags read FFlags write FFlags;
|
||||
property UseCache: boolean read FUseCache write SetUseCache;
|
||||
property IsTComponent: boolean read FIsTComponent;
|
||||
property IsTControl: boolean read FIsTControl;
|
||||
property IsTWinControl: boolean read FIsTWinControl;
|
||||
property IsNonVisualComponent: boolean read FIsNonVisualComponent;
|
||||
property DesignerForm: TCustomForm read FDesignerForm;
|
||||
property MarkerPaintedBounds: TRect read FMarkerPaintedBounds write FMarkerPaintedBounds;
|
||||
end;
|
||||
@ -230,9 +237,17 @@ type
|
||||
cssGuideLinesPainted
|
||||
);
|
||||
TControlSelStates = set of TControlSelState;
|
||||
|
||||
const
|
||||
cssSelectionChangeFlags =
|
||||
[cssOnlyNonVisualNeedsUpdate,cssOnlyVisualNeedsUpdate,
|
||||
cssOnlyInvisibleNeedsUpdate,cssOnlyBoundLessNeedsUpdate,
|
||||
cssParentLevelNeedsUpdate,cssParentChildFlagsNeedUpdate];
|
||||
|
||||
type
|
||||
|
||||
TControlSelection = class(TObject)
|
||||
FControls: TList; // list of TSelectedComponent
|
||||
FControls: TList; // list of TSelectedControl
|
||||
|
||||
// current bounds of the selection (only valid if Count>0)
|
||||
// These are the values set by the user
|
||||
@ -319,7 +334,7 @@ type
|
||||
// snapping
|
||||
function CleanGridSizeX: integer;
|
||||
function CleanGridSizeY: integer;
|
||||
function ComponentAlignable(AComponent: TComponent): boolean;
|
||||
function PersistentAlignable(APersistent: TPersistent): boolean;
|
||||
function GetBottomGuideLine(var ALine: TRect): boolean;
|
||||
function GetLeftGuideLine(var ALine: TRect): boolean;
|
||||
function GetRightGuideLine(var ALine: TRect): boolean;
|
||||
@ -351,21 +366,21 @@ type
|
||||
procedure EndUpdate;
|
||||
property UpdateLock: integer read FUpdateLock;
|
||||
|
||||
function IndexOf(AComponent:TComponent):integer;
|
||||
function Add(AComponent: TComponent):integer;
|
||||
procedure Remove(AComponent: TComponent);
|
||||
function IndexOf(APersistent: TPersistent):integer;
|
||||
function Add(APersistent: TPersistent):integer;
|
||||
procedure Remove(APersistent: TPersistent);
|
||||
procedure Delete(Index:integer);
|
||||
procedure Clear;
|
||||
function AssignComponent(AComponent:TComponent): boolean;
|
||||
function AssignPersistent(APersistent: TPersistent): boolean;
|
||||
procedure Assign(AControlSelection: TControlSelection);
|
||||
procedure AssignSelection(const ASelection: TPersistentSelectionList);
|
||||
function IsSelected(AComponent: TComponent): Boolean;
|
||||
function IsOnlySelected(AComponent: TComponent): Boolean;
|
||||
function IsSelected(APersistent: TPersistent): Boolean;
|
||||
function IsOnlySelected(APersistent: TPersistent): Boolean;
|
||||
procedure SaveBounds;
|
||||
function ParentLevel: integer;
|
||||
function OnlyNonVisualComponentsSelected: boolean;
|
||||
function OnlyNonVisualPersistentsSelected: boolean;
|
||||
function OnlyVisualComponentsSelected: boolean;
|
||||
function OnlyInvisibleComponentsSelected: boolean;
|
||||
function OnlyInvisiblePersistensSelected: boolean;
|
||||
function OnlyBoundLessComponentsSelected: boolean;
|
||||
function LookupRootSelected: boolean;
|
||||
|
||||
@ -522,13 +537,17 @@ end;
|
||||
{ TSelectedControl }
|
||||
|
||||
constructor TSelectedControl.Create(AnOwner: TControlSelection;
|
||||
AComponent:TComponent);
|
||||
APersistent: TPersistent);
|
||||
begin
|
||||
inherited Create;
|
||||
FOwner:=AnOwner;
|
||||
FComponent:=AComponent;
|
||||
FIsTControl:=FComponent is TControl;
|
||||
FDesignerForm:=GetDesignerForm(FComponent);
|
||||
FPersistent:=APersistent;
|
||||
FIsTComponent:=FPersistent is TComponent;
|
||||
FIsTControl:=FPersistent is TControl;
|
||||
FIsTWinControl:=FPersistent is TWinControl;
|
||||
FIsNonVisualComponent:=FIsTComponent and (not FIsTControl);
|
||||
if FIsTComponent then
|
||||
FDesignerForm:=GetDesignerForm(TComponent(FPersistent));
|
||||
end;
|
||||
|
||||
destructor TSelectedControl.Destroy;
|
||||
@ -539,17 +558,17 @@ end;
|
||||
procedure TSelectedControl.SetBounds(ALeft, ATop, AWidth, AHeight: integer);
|
||||
begin
|
||||
if FIsTControl then begin
|
||||
TControl(FComponent).SetBounds(ALeft, ATop, AWidth, AHeight);
|
||||
TControl(FPersistent).SetBounds(ALeft, ATop, AWidth, AHeight);
|
||||
FCachedLeft:=ALeft;
|
||||
FCachedTop:=ATop;
|
||||
FCachedWidth:=AWidth;
|
||||
FCachedHeight:=AHeight;
|
||||
end else begin
|
||||
end else if FIsTComponent then begin
|
||||
if (Left<>ALeft) or (Top<>ATop) then begin
|
||||
InvalidateNonVisualComponent;
|
||||
InvalidateNonVisualPersistent;
|
||||
Left:=ALeft;
|
||||
Top:=ATop;
|
||||
InvalidateNonVisualComponent;
|
||||
InvalidateNonVisualPersistent;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -559,31 +578,53 @@ procedure TSelectedControl.SetFormRelativeBounds(ALeft, ATop, AWidth,
|
||||
var
|
||||
ParentOffset: TPoint;
|
||||
begin
|
||||
ParentOffset:=GetParentFormRelativeParentClientOrigin(FComponent);
|
||||
//writeln('TSelectedControl.SetFormRelativeBounds ',FComponent.Name,
|
||||
// ' Left=',ALeft,' LeftOff=',ParentOffset.X,
|
||||
// ' Top=',ATop,' TopOff=',ParentOffset.Y);
|
||||
if not FIsTComponent then exit;
|
||||
ParentOffset:=
|
||||
GetParentFormRelativeParentClientOrigin(TComponent(FPersistent));
|
||||
SetBounds(ALeft-ParentOffset.X,ATop-ParentOffset.Y,AWidth,AHeight);
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.GetFormRelativeBounds(var ALeft, ATop, AWidth,
|
||||
AHeight: integer);
|
||||
var
|
||||
ALeftTop: TPoint;
|
||||
begin
|
||||
if FIsTComponent then begin
|
||||
GetComponentBounds(TComponent(FPersistent),ALeft,ATop,AWidth,AHeight);
|
||||
ALeftTop:=GetParentFormRelativeTopLeft(TComponent(FPersistent));
|
||||
ALeft:=ALeftTop.X;
|
||||
ATop:=ALeftTop.Y;
|
||||
end else begin
|
||||
ALeft:=0;
|
||||
ATop:=0;
|
||||
AWidth:=0;
|
||||
AHeight:=0;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SaveBounds;
|
||||
begin
|
||||
GetComponentBounds(FComponent,FOldLeft,FOldTop,FOldWidth,FOldHeight);
|
||||
FOldFormRelativeLeftTop:=GetParentFormRelativeTopLeft(FComponent);
|
||||
//writeln('[TSelectedControl.SaveBounds] ',Component.Name,':',Component.ClassName
|
||||
// ,' ',FOldLeft,',',FOldTop);
|
||||
if not FIsTComponent then exit;
|
||||
GetComponentBounds(TComponent(FPersistent),
|
||||
FOldLeft,FOldTop,FOldWidth,FOldHeight);
|
||||
FOldFormRelativeLeftTop:=
|
||||
GetParentFormRelativeTopLeft(TComponent(FPersistent));
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.UpdateCache;
|
||||
begin
|
||||
GetComponentBounds(FComponent,FCachedLeft,FCachedTop,FCachedWidth,FCachedHeight);
|
||||
FCachedFormRelativeLeftTop:=GetParentFormRelativeTopLeft(FComponent);
|
||||
if not FIsTComponent then exit;
|
||||
GetComponentBounds(TComponent(FPersistent),
|
||||
FCachedLeft,FCachedTop,FCachedWidth,FCachedHeight);
|
||||
FCachedFormRelativeLeftTop:=
|
||||
GetParentFormRelativeTopLeft(TComponent(FPersistent));
|
||||
end;
|
||||
|
||||
function TSelectedControl.IsTopLvl: boolean;
|
||||
begin
|
||||
Result:=(FComponent.Owner=nil)
|
||||
or (FIsTControl and (TControl(FComponent).Parent=nil));
|
||||
Result:=(not FIsTComponent)
|
||||
or (TComponent(FPersistent).Owner=nil)
|
||||
or (FIsTControl and (TControl(FPersistent).Parent=nil));
|
||||
end;
|
||||
|
||||
function TSelectedControl.ChildInSelection: boolean;
|
||||
@ -606,15 +647,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.InvalidateNonVisualComponent;
|
||||
procedure TSelectedControl.InvalidateNonVisualPersistent;
|
||||
var
|
||||
AForm: TCustomForm;
|
||||
CompRect: TRect;
|
||||
begin
|
||||
AForm:=DesignerForm;
|
||||
if (AForm=nil) then exit;
|
||||
CompRect.Left:=LongRec(FComponent.DesignInfo).Lo;
|
||||
CompRect.Top:=LongRec(FComponent.DesignInfo).Hi;
|
||||
if (AForm=nil) or (not FIsTComponent) then exit;
|
||||
CompRect.Left:=LongRec(TComponent(FPersistent).DesignInfo).Lo;
|
||||
CompRect.Top:=LongRec(TComponent(FPersistent).DesignInfo).Hi;
|
||||
CompRect.Right:=CompRect.Left+NonVisualCompWidth;
|
||||
CompRect.Bottom:=CompRect.Top+NonVisualCompWidth;
|
||||
//writeln('TSelectedControl.InvalidateNonVisualComponent A ',CompRect.Left,',',CompRect.Top,',',CompRect.Right,',',CompRect.Bottom);
|
||||
@ -625,16 +666,19 @@ function TSelectedControl.GetLeft: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedLeft
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentLeft(TComponent(FPersistent))
|
||||
else
|
||||
Result:=GetComponentLeft(FComponent);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetLeft(ALeft: integer);
|
||||
begin
|
||||
if FIsTControl then
|
||||
TControl(FComponent).Left:=Aleft
|
||||
else
|
||||
LongRec(FComponent.DesignInfo).Lo:=word(Min(32000,Max(0,ALeft)));
|
||||
TControl(FPersistent).Left:=Aleft
|
||||
else if FIsTComponent then
|
||||
LongRec(TComponent(FPersistent).DesignInfo).Lo:=
|
||||
word(Min(32000,Max(0,ALeft)));
|
||||
FCachedLeft:=ALeft;
|
||||
end;
|
||||
|
||||
@ -642,8 +686,10 @@ function TSelectedControl.GetTop: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedTop
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentTop(TComponent(FPersistent))
|
||||
else
|
||||
Result:=GetComponentTop(FComponent);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetOwner(const AValue: TControlSelection);
|
||||
@ -655,9 +701,10 @@ end;
|
||||
procedure TSelectedControl.SetTop(ATop: integer);
|
||||
begin
|
||||
if FIsTControl then
|
||||
TControl(FComponent).Top:=ATop
|
||||
else
|
||||
LongRec(FComponent.DesignInfo).Hi:=word(Min(32000,Max(0,ATop)));
|
||||
TControl(FPersistent).Top:=ATop
|
||||
else if FIsTComponent then
|
||||
LongRec(TComponent(FPersistent).DesignInfo).Hi:=
|
||||
word(Min(32000,Max(0,ATop)));
|
||||
FCachedTop:=ATop;
|
||||
end;
|
||||
|
||||
@ -665,8 +712,8 @@ function TSelectedControl.GetWidth: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedWidth
|
||||
else
|
||||
Result:=GetComponentWidth(FComponent);
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentWidth(TComponent(FPersistent));
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetUseCache(const AValue: boolean);
|
||||
@ -679,9 +726,7 @@ end;
|
||||
procedure TSelectedControl.SetWidth(AWidth: integer);
|
||||
begin
|
||||
if FIsTControl then
|
||||
TControl(FComponent).Width:=AWidth
|
||||
else
|
||||
;
|
||||
TControl(FPersistent).Width:=AWidth;
|
||||
FCachedWidth:=AWidth;
|
||||
end;
|
||||
|
||||
@ -689,16 +734,16 @@ function TSelectedControl.GetHeight: integer;
|
||||
begin
|
||||
if FUseCache then
|
||||
Result:=FCachedHeight
|
||||
else if FIsTComponent then
|
||||
Result:=GetComponentHeight(TComponent(FPersistent))
|
||||
else
|
||||
Result:=GetComponentHeight(FComponent);
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
procedure TSelectedControl.SetHeight(AHeight: integer);
|
||||
begin
|
||||
if FIsTControl then
|
||||
TControl(FComponent).Height:=AHeight
|
||||
else
|
||||
;
|
||||
TControl(FPersistent).Height:=AHeight;
|
||||
FCachedHeight:=AHeight;
|
||||
end;
|
||||
|
||||
@ -1000,7 +1045,7 @@ begin
|
||||
if NewHeight<1 then NewHeight:=1;
|
||||
Items[i].SetFormRelativeBounds(NewLeft,NewTop,NewWidth,NewHeight);
|
||||
{$IFDEF VerboseDesigner}
|
||||
writeln(' i=',i,' ',Items[i].Component.Name,
|
||||
writeln(' i=',i,' ',Items[i].Persistent.Name,
|
||||
' ',Items[i].Left,',',Items[i].Top,',',Items[i].Width,',',Items[i].Height);
|
||||
{$ENDIF}
|
||||
end;
|
||||
@ -1012,27 +1057,25 @@ begin
|
||||
end;
|
||||
|
||||
procedure TControlSelection.UpdateRealBounds;
|
||||
var i:integer;
|
||||
LeftTop: TPoint;
|
||||
var
|
||||
i: integer;
|
||||
NextRealLeft, NextRealTop, NextRealHeight, NextRealWidth: integer;
|
||||
begin
|
||||
if FControls.Count>=1 then begin
|
||||
LeftTop:=GetParentFormRelativeTopLeft(Items[0].Component);
|
||||
FRealLeft:=LeftTop.X;
|
||||
FRealTop:=LeftTop.Y;
|
||||
FRealHeight:=Items[0].Height;
|
||||
FRealWidth:=Items[0].Width;
|
||||
Items[0].GetFormRelativeBounds(FRealLeft,FRealTop,FRealWidth,FRealHeight);
|
||||
for i:=1 to FControls.Count-1 do begin
|
||||
LeftTop:=GetParentFormRelativeTopLeft(Items[i].Component);
|
||||
if FRealLeft>LeftTop.X then begin
|
||||
inc(FRealWidth,FRealLeft-LeftTop.X);
|
||||
FRealLeft:=LeftTop.X;
|
||||
Items[i].GetFormRelativeBounds(
|
||||
NextRealLeft,NextRealTop,NextRealWidth,NextRealHeight);
|
||||
if FRealLeft>NextRealLeft then begin
|
||||
inc(FRealWidth,FRealLeft-NextRealLeft);
|
||||
FRealLeft:=NextRealLeft;
|
||||
end;
|
||||
if FRealTop>LeftTop.Y then begin
|
||||
inc(FRealHeight,FRealTop-LeftTop.Y);
|
||||
FRealTop:=LeftTop.Y;
|
||||
if FRealTop>NextRealTop then begin
|
||||
inc(FRealHeight,FRealTop-NextRealTop);
|
||||
FRealTop:=NextRealTop;
|
||||
end;
|
||||
FRealWidth:=Max(FRealLeft+FRealWidth,LeftTop.X+Items[i].Width)-FRealLeft;
|
||||
FRealHeight:=Max(FRealTop+FRealHeight,LeftTop.Y+Items[i].Height)-FRealTop;
|
||||
FRealWidth:=Max(FRealLeft+FRealWidth,NextRealLeft+NextRealWidth)-FRealLeft;
|
||||
FRealHeight:=Max(FRealTop+FRealHeight,NextRealTop+NextRealHeight)-FRealTop;
|
||||
end;
|
||||
AdjustGrabbers;
|
||||
InvalidateGuideLines;
|
||||
@ -1048,15 +1091,14 @@ begin
|
||||
if not (cssParentChildFlagsNeedUpdate in FStates) then exit;
|
||||
Cnt:=Count;
|
||||
for i:=0 to Cnt-1 do begin
|
||||
Control1:=TControl(Items[i].Component);
|
||||
Items[i].FFlags:=Items[i].FFlags-[scfParentInSelection,scfChildInSelection];
|
||||
end;
|
||||
for i:=0 to Cnt-1 do begin
|
||||
Control1:=TControl(Items[i].Component);
|
||||
if not (Control1 is TControl) then continue;
|
||||
if not Items[i].IsTControl then continue;
|
||||
Control1:=TControl(Items[i].Persistent);
|
||||
for j:=0 to Cnt-1 do begin
|
||||
Control2:=TControl(Items[j].Component);
|
||||
if not (Control2 is TControl) then continue;
|
||||
if not Items[j].IsTControl then continue;
|
||||
Control2:=TControl(Items[j].Persistent);
|
||||
if i=j then continue;
|
||||
if Control1.IsParentOf(Control2) then begin
|
||||
Include(Items[i].FFlags,scfChildInSelection);
|
||||
@ -1076,7 +1118,8 @@ var
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
CurItem:=Items[Index];
|
||||
AComponent:=CurItem.Component;
|
||||
if not CurItem.IsTComponent then exit;
|
||||
AComponent:=TComponent(CurItem.Persistent);
|
||||
|
||||
GetComponentBounds(AComponent,CompLeft,CompTop,CompWidth,CompHeight);
|
||||
CompOrigin:=GetParentFormRelativeParentClientOrigin(AComponent);
|
||||
@ -1106,11 +1149,15 @@ begin
|
||||
if Result<1 then Result:=1;
|
||||
end;
|
||||
|
||||
function TControlSelection.ComponentAlignable(AComponent: TComponent): boolean;
|
||||
function TControlSelection.PersistentAlignable(
|
||||
APersistent: TPersistent): boolean;
|
||||
var
|
||||
CurParentLevel: integer;
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
Result:=false;
|
||||
if not (APersistent is TComponent) then exit;
|
||||
AComponent:=TComponent(APersistent);
|
||||
if AComponent=nil then exit;
|
||||
if AComponent is TControl then begin
|
||||
if not ControlIsInDesignerVisible(TControl(AComponent)) then begin
|
||||
@ -1118,8 +1165,8 @@ begin
|
||||
exit;
|
||||
end;
|
||||
if Count>0 then begin
|
||||
if OnlyNonVisualComponentsSelected then begin
|
||||
//writeln('not alignable: B OnlyNonVisualComponentsSelected ',AComponent.Name);
|
||||
if OnlyNonVisualPersistentsSelected then begin
|
||||
//writeln('not alignable: B OnlyNonVisualPersistentsSelected ',AComponent.Name);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -1227,7 +1274,8 @@ end;
|
||||
|
||||
procedure TControlSelection.FindNearestLeftGuideLine(
|
||||
var NearestInt: TNearestInt);
|
||||
var i, CurLeft, MaxDist, CurDist: integer;
|
||||
var
|
||||
i, CurLeft, MaxDist, CurDist: integer;
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
if (not EnvironmentOptions.SnapToGuideLines) or (FLookupRoot=nil) then exit;
|
||||
@ -1235,7 +1283,7 @@ begin
|
||||
MaxDist:=(CleanGridSizeX+1) div 2;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FLookupRoot.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
if IsSelected(AComponent) then continue;
|
||||
CurLeft:=GetParentFormRelativeTopLeft(AComponent).X;
|
||||
CurDist:=Abs(CurLeft-NearestInt.Level);
|
||||
@ -1254,7 +1302,7 @@ begin
|
||||
MaxDist:=(CleanGridSizeX+1) div 2;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FLookupRoot.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
if IsSelected(AComponent) then continue;
|
||||
CurRight:=GetParentFormRelativeTopLeft(AComponent).X
|
||||
+GetComponentWidth(AComponent);
|
||||
@ -1274,7 +1322,7 @@ begin
|
||||
MaxDist:=(CleanGridSizeY+1) div 2;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FLookupRoot.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
if IsSelected(AComponent) then continue;
|
||||
CurTop:=GetParentFormRelativeTopLeft(AComponent).Y;
|
||||
CurDist:=Abs(CurTop-NearestInt.Level);
|
||||
@ -1293,7 +1341,7 @@ begin
|
||||
MaxDist:=(CleanGridSizeY+1) div 2;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FLookupRoot.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
if IsSelected(AComponent) then continue;
|
||||
CurBottom:=GetParentFormRelativeTopLeft(AComponent).Y
|
||||
+GetComponentHeight(AComponent);
|
||||
@ -1458,7 +1506,7 @@ begin
|
||||
if FForm=nil then exit;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FLookupRoot.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
CRect:=GetParentFormRelativeBounds(AComponent);
|
||||
if CRect.Left=FRealLeft then begin
|
||||
ALine.Left:=FRealLeft;
|
||||
@ -1502,7 +1550,7 @@ begin
|
||||
if FLookupRoot=nil then exit;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FForm.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
CRect:=GetParentFormRelativeBounds(AComponent);
|
||||
if (CRect.Right=FRealLeft+FRealWidth) then begin
|
||||
ALine.Left:=CRect.Right;
|
||||
@ -1546,7 +1594,7 @@ begin
|
||||
if FLookupRoot=nil then exit;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FForm.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
CRect:=GetParentFormRelativeBounds(AComponent);
|
||||
if CRect.Top=FRealTop then begin
|
||||
ALine.Top:=FRealTop;
|
||||
@ -1590,19 +1638,19 @@ begin
|
||||
if FLookupRoot=nil then exit;
|
||||
for i:=0 to FLookupRoot.ComponentCount-1 do begin
|
||||
AComponent:=FForm.Components[i];
|
||||
if not ComponentAlignable(AComponent) then continue;
|
||||
if not PersistentAlignable(AComponent) then continue;
|
||||
CRect:=GetParentFormRelativeBounds(AComponent);
|
||||
if CRect.Bottom=FRealTop+FRealHeight then begin
|
||||
ALine.Top:=CRect.Bottom;
|
||||
ALine.Bottom:=ALine.Top;
|
||||
LineLeft:=Min(Min(Min(FRealLeft,
|
||||
FRealLeft+FRealWidth),
|
||||
CRect.Left),
|
||||
CRect.Right);
|
||||
FRealLeft+FRealWidth),
|
||||
CRect.Left),
|
||||
CRect.Right);
|
||||
LineRight:=Max(Max(Max(FRealLeft,
|
||||
FRealLeft+FRealWidth),
|
||||
CRect.Left),
|
||||
CRect.Right);
|
||||
FRealLeft+FRealWidth),
|
||||
CRect.Left),
|
||||
CRect.Right);
|
||||
if Result then begin
|
||||
LineLeft:=Min(ALine.Left,LineLeft);
|
||||
LineRight:=Max(ALine.Right,LineRight);
|
||||
@ -1633,8 +1681,8 @@ function TControlSelection.ParentLevel: integer;
|
||||
begin
|
||||
if (cssParentLevelNeedsUpdate in FStates) then begin
|
||||
if (Count>0) and OnlyVisualComponentsSelected
|
||||
and (Items[0].Component is TControl) then
|
||||
FParentLevel:=GetParentLevel(TControl(Items[0].Component))
|
||||
and (Items[0].IsTControl) then
|
||||
FParentLevel:=GetParentLevel(TControl(Items[0].Persistent))
|
||||
else
|
||||
FParentLevel:=0;
|
||||
Exclude(FStates,cssParentLevelNeedsUpdate);
|
||||
@ -1751,44 +1799,43 @@ begin
|
||||
Result:=FControls.Count;
|
||||
end;
|
||||
|
||||
function TControlSelection.IndexOf(AComponent:TComponent):integer;
|
||||
function TControlSelection.IndexOf(APersistent: TPersistent): integer;
|
||||
begin
|
||||
Result:=Count-1;
|
||||
while (Result>=0) and (Items[Result].Component<>AComponent) do dec(Result);
|
||||
while (Result>=0) and (Items[Result].Persistent<>APersistent) do dec(Result);
|
||||
end;
|
||||
|
||||
function TControlSelection.Add(AComponent: TComponent):integer;
|
||||
var NewSelectedControl:TSelectedControl;
|
||||
function TControlSelection.Add(APersistent: TPersistent): integer;
|
||||
var
|
||||
NewSelectedControl: TSelectedControl;
|
||||
begin
|
||||
BeginUpdate;
|
||||
NewSelectedControl:=TSelectedControl.Create(Self,AComponent);
|
||||
NewSelectedControl:=TSelectedControl.Create(Self,APersistent);
|
||||
if NewSelectedControl.DesignerForm<>FForm then Clear;
|
||||
Result:=FControls.Add(NewSelectedControl);
|
||||
FStates:=FStates+[cssOnlyNonVisualNeedsUpdate,cssOnlyVisualNeedsUpdate,
|
||||
cssOnlyInvisibleNeedsUpdate,cssOnlyBoundLessNeedsUpdate,
|
||||
cssParentLevelNeedsUpdate,cssParentChildFlagsNeedUpdate];
|
||||
FStates:=FStates+cssSelectionChangeFlags;
|
||||
if Count=1 then SetCustomForm;
|
||||
if AComponent=FLookupRoot then Include(FStates,cssLookupRootSelected);
|
||||
if APersistent=FLookupRoot then Include(FStates,cssLookupRootSelected);
|
||||
DoChange;
|
||||
UpdateBounds;
|
||||
SaveBounds;
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
function TControlSelection.AssignComponent(AComponent: TComponent): boolean;
|
||||
function TControlSelection.AssignPersistent(APersistent: TPersistent): boolean;
|
||||
begin
|
||||
Result:=not IsOnlySelected(AComponent);
|
||||
Result:=not IsOnlySelected(APersistent);
|
||||
if not Result then exit;
|
||||
BeginUpdate;
|
||||
Clear;
|
||||
Add(AComponent);
|
||||
Add(APersistent);
|
||||
EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TControlSelection.Remove(AComponent: TComponent);
|
||||
procedure TControlSelection.Remove(APersistent: TPersistent);
|
||||
var i:integer;
|
||||
begin
|
||||
i:=IndexOf(AComponent);
|
||||
i:=IndexOf(APersistent);
|
||||
if i>=0 then Delete(i);
|
||||
end;
|
||||
|
||||
@ -1801,13 +1848,11 @@ begin
|
||||
InvalidateGrabbers;
|
||||
InvalidateGuideLines;
|
||||
end;
|
||||
if Items[Index].Component=FLookupRoot then
|
||||
if Items[Index].Persistent=FLookupRoot then
|
||||
Exclude(FStates,cssLookupRootSelected);
|
||||
Items[Index].Free;
|
||||
FControls.Delete(Index);
|
||||
FStates:=FStates+[cssOnlyNonVisualNeedsUpdate,cssOnlyVisualNeedsUpdate,
|
||||
cssOnlyInvisibleNeedsUpdate,cssOnlyBoundLessNeedsUpdate,
|
||||
cssParentLevelNeedsUpdate,cssParentChildFlagsNeedUpdate];
|
||||
FStates:=FStates+cssSelectionChangeFlags;
|
||||
|
||||
if Count=0 then SetCustomForm;
|
||||
UpdateBounds;
|
||||
@ -1824,17 +1869,14 @@ begin
|
||||
InvalidateGuideLines;
|
||||
for i:=0 to FControls.Count-1 do Items[i].Free;
|
||||
FControls.Clear;
|
||||
FStates:=FStates+[cssOnlyNonVisualNeedsUpdate,cssOnlyVisualNeedsUpdate,
|
||||
cssOnlyInvisibleNeedsUpdate,cssOnlyBoundLessNeedsUpdate,
|
||||
cssParentLevelNeedsUpdate,cssParentChildFlagsNeedUpdate]
|
||||
-[cssLookupRootSelected];
|
||||
FStates:=FStates+cssSelectionChangeFlags-[cssLookupRootSelected];
|
||||
FForm:=nil;
|
||||
UpdateBounds;
|
||||
SaveBounds;
|
||||
DoChange;
|
||||
end;
|
||||
|
||||
procedure TControlSelection.Assign(AControlSelection:TControlSelection);
|
||||
procedure TControlSelection.Assign(AControlSelection: TControlSelection);
|
||||
var i:integer;
|
||||
begin
|
||||
if (AControlSelection=Self) or (cssNotSavingBounds in FStates) then exit;
|
||||
@ -1843,7 +1885,7 @@ begin
|
||||
Clear;
|
||||
FControls.Capacity:=AControlSelection.Count;
|
||||
for i:=0 to AControlSelection.Count-1 do
|
||||
Add(AControlSelection[i].Component);
|
||||
Add(AControlSelection[i].Persistent);
|
||||
SetCustomForm;
|
||||
UpdateBounds;
|
||||
Exclude(FStates,cssNotSavingBounds);
|
||||
@ -1866,7 +1908,7 @@ begin
|
||||
for i:=0 to ASelection.Count-1 do
|
||||
begin
|
||||
Instance := ASelection[i];
|
||||
if Instance is TComponent then Add(TComponent(Instance));
|
||||
if Instance is TPersistent then Add(Instance);
|
||||
end;
|
||||
SetCustomForm;
|
||||
UpdateBounds;
|
||||
@ -1876,14 +1918,14 @@ begin
|
||||
DoChange;
|
||||
end;
|
||||
|
||||
function TControlSelection.IsSelected(AComponent: TComponent): Boolean;
|
||||
function TControlSelection.IsSelected(APersistent: TPersistent): Boolean;
|
||||
begin
|
||||
Result:=(IndexOf(AComponent)>=0);
|
||||
Result:=(IndexOf(APersistent)>=0);
|
||||
end;
|
||||
|
||||
function TControlSelection.IsOnlySelected(AComponent: TComponent): Boolean;
|
||||
function TControlSelection.IsOnlySelected(APersistent: TPersistent): Boolean;
|
||||
begin
|
||||
Result:=(Count=1) and (Items[0].Component=AComponent);
|
||||
Result:=(Count=1) and (Items[0].Persistent=APersistent);
|
||||
end;
|
||||
|
||||
procedure TControlSelection.MoveSelection(dx, dy: integer);
|
||||
@ -2072,7 +2114,8 @@ var
|
||||
begin
|
||||
if (Count<2) or (FForm=nil) then exit;
|
||||
for i:=0 to Count-1 do begin
|
||||
AComponent:=Items[i].Component;
|
||||
if not Items[i].IsTComponent then continue;
|
||||
AComponent:=TComponent(Items[i].Persistent);
|
||||
if (AComponent=FLookupRoot)
|
||||
or ComponentIsInvisible(AComponent) then continue;
|
||||
DoDrawMarker(i,DC);
|
||||
@ -2317,7 +2360,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TControlSelection.OnlyNonVisualComponentsSelected: boolean;
|
||||
function TControlSelection.OnlyNonVisualPersistentsSelected: boolean;
|
||||
var i: integer;
|
||||
begin
|
||||
if cssOnlyNonVisualNeedsUpdate in FStates then begin
|
||||
@ -2355,16 +2398,18 @@ begin
|
||||
Result:=cssOnlyVisualNeedsSelected in FStates;
|
||||
end;
|
||||
|
||||
function TControlSelection.OnlyInvisibleComponentsSelected: boolean;
|
||||
function TControlSelection.OnlyInvisiblePersistensSelected: boolean;
|
||||
var i: integer;
|
||||
begin
|
||||
if cssOnlyInvisibleNeedsUpdate in FStates then begin
|
||||
Result:=true;
|
||||
for i:=0 to FControls.Count-1 do
|
||||
if not ComponentIsInvisible(Items[i].Component) then begin
|
||||
for i:=0 to FControls.Count-1 do begin
|
||||
if (not Items[i].IsTComponent)
|
||||
or (not ComponentIsInvisible(TComponent(Items[i].Persistent))) then begin
|
||||
Result:=false;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
if Result then
|
||||
Include(FStates,cssOnlyInvisibleSelected)
|
||||
else
|
||||
@ -2381,7 +2426,8 @@ begin
|
||||
if cssOnlyBoundLessNeedsUpdate in FStates then begin
|
||||
Result:=true;
|
||||
for i:=0 to FControls.Count-1 do
|
||||
if ComponentBoundsDesignable(Items[i].Component) then begin
|
||||
if Items[i].IsTComponent
|
||||
and ComponentBoundsDesignable(TComponent(Items[i].Persistent)) then begin
|
||||
Result:=false;
|
||||
break;
|
||||
end;
|
||||
@ -2666,10 +2712,10 @@ begin
|
||||
// size components
|
||||
for i:=0 to FControls.Count-1 do begin
|
||||
if Items[i].IsTopLvl then continue;
|
||||
if (Items[i].Component is TControl) then begin
|
||||
if (Items[i].IsTControl) then begin
|
||||
if HorizSizing=cssNone then AWidth:=Items[i].Width;
|
||||
if VertSizing=cssNone then AHeight:=Items[i].Height;
|
||||
TControl(Items[i].Component).SetBounds(Items[i].Left,Items[i].Top,
|
||||
TControl(Items[i].Persistent).SetBounds(Items[i].Left,Items[i].Top,
|
||||
Max(1,AWidth), Max(1,AHeight));
|
||||
end;
|
||||
end;
|
||||
@ -2687,8 +2733,8 @@ begin
|
||||
if Percent>1000 then Percent:=1000;
|
||||
// size components
|
||||
for i:=0 to FControls.Count-1 do begin
|
||||
if Items[i].Component is TControl then begin
|
||||
TControl(Items[i].Component).SetBounds(
|
||||
if Items[i].IsTControl then begin
|
||||
TControl(Items[i].Persistent).SetBounds(
|
||||
Items[i].Left,
|
||||
Items[i].Top,
|
||||
Max(1,(Items[i].Width*Percent) div 100),
|
||||
@ -2793,8 +2839,8 @@ function TControlSelection.GetSelectionOwner: TComponent;
|
||||
var
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
if FControls.Count>0 then begin
|
||||
AComponent:=Items[0].Component;
|
||||
if (FControls.Count>0) and (Items[0].IsTComponent) then begin
|
||||
AComponent:=TComponent(Items[0].Persistent);
|
||||
if AComponent.Owner<>nil then
|
||||
Result:=AComponent.Owner
|
||||
else
|
||||
|
@ -36,8 +36,8 @@ interface
|
||||
{ $DEFINE VerboseDesignerDraw}
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Math, LCLType, LCLIntf, Forms, Controls, LMessages,
|
||||
GraphType, Graphics, Dialogs, ExtCtrls, Menus, ClipBrd,
|
||||
Classes, SysUtils, Math, LCLProc, LCLType, LCLIntf, LMessages,
|
||||
Forms, Controls, GraphType, Graphics, Dialogs, ExtCtrls, Menus, ClipBrd,
|
||||
LazarusIDEStrConsts, EnvironmentOpts, KeyMapping, ComponentReg,
|
||||
NonControlForms, AlignCompsDlg, SizeCompsDlg, ScaleCompsDlg, TabOrderDlg,
|
||||
DesignerProcs, PropEdits, ComponentEditors, CustomFormEditor,
|
||||
@ -50,14 +50,14 @@ type
|
||||
var RegisteredComponent: TRegisteredComponent) of object;
|
||||
TOnSetDesigning = procedure(Sender: TObject; Component: TComponent;
|
||||
Value: boolean) of object;
|
||||
TOnComponentAdded = procedure(Sender: TObject; Component: TComponent;
|
||||
TOnPersistentAdded = procedure(Sender: TObject; APersistent: TPersistent;
|
||||
ComponentClass: TRegisteredComponent) of object;
|
||||
TOnPasteComponent = procedure(Sender: TObject; LookupRoot: TComponent;
|
||||
TxtCompStream: TStream; ParentControl: TWinControl;
|
||||
var NewComponent: TComponent) of object;
|
||||
TOnRemoveComponent = procedure(Sender: TObject; Component: TComponent)
|
||||
TOnRemovePersistent = procedure(Sender: TObject; APersistent: TPersistent)
|
||||
of object;
|
||||
TOnComponentDeleted = procedure(Sender: TObject; Component: TComponent)
|
||||
TOnPersistentDeleted = procedure(Sender: TObject; APersistent: TPersistent)
|
||||
of object;
|
||||
TOnGetNonVisualCompIconCanvas = procedure(Sender: TObject;
|
||||
AComponent: TComponent; var IconCanvas: TCanvas;
|
||||
@ -93,15 +93,15 @@ type
|
||||
FMirrorVerticalMenuItem: TMenuItem;
|
||||
FOnActivated: TNotifyEvent;
|
||||
FOnCloseQuery: TNotifyEvent;
|
||||
FOnComponentAdded: TOnComponentAdded;
|
||||
FOnComponentDeleted: TOnComponentDeleted;
|
||||
FOnPersistentAdded: TOnPersistentAdded;
|
||||
FOnPersistentDeleted: TOnPersistentDeleted;
|
||||
FOnGetNonVisualCompIconCanvas: TOnGetNonVisualCompIconCanvas;
|
||||
FOnGetSelectedComponentClass: TOnGetSelectedComponentClass;
|
||||
FOnModified: TNotifyEvent;
|
||||
FOnPasteComponent: TOnPasteComponent;
|
||||
FOnProcessCommand: TOnProcessCommand;
|
||||
FOnPropertiesChanged: TNotifyEvent;
|
||||
FOnRemoveComponent: TOnRemoveComponent;
|
||||
FOnRemovePersistent: TOnRemovePersistent;
|
||||
FOnRenameComponent: TOnRenameComponent;
|
||||
FOnSetDesigning: TOnSetDesigning;
|
||||
FOnShowOptions: TNotifyEvent;
|
||||
@ -149,8 +149,8 @@ type
|
||||
LastMouseMovePos: TPoint;
|
||||
PopupMenuComponentEditor: TBaseComponentEditor;
|
||||
LastFormCursor: TCursor;
|
||||
DeletingComponents: TList;
|
||||
IgnoreDeletingComponents: TList;
|
||||
DeletingPersistent: TList;
|
||||
IgnoreDeletingPersistent: TList;
|
||||
|
||||
LastPaintSender: TControl;
|
||||
|
||||
@ -165,11 +165,11 @@ type
|
||||
Procedure KeyUp(Sender: TControl; var TheMessage:TLMKEY);
|
||||
function HandleSetCursor(var TheMessage: TLMessage): boolean;
|
||||
|
||||
// procedures for working with components
|
||||
procedure DoDeleteSelectedComponents;
|
||||
procedure DoDeleteComponent(AComponent: TComponent; FreeComponent: boolean);
|
||||
procedure MarkComponentForDeletion(AComponent: TComponent);
|
||||
function ComponentIsMarkedForDeletion(AComponent: TComponent): boolean;
|
||||
// procedures for working with components and persistents
|
||||
procedure DoDeleteSelectedPersistents;
|
||||
procedure DoDeletePersistent(APersistent: TPersistent; FreeIt: boolean);
|
||||
procedure MarkPersistentForDeletion(APersistent: TPersistent);
|
||||
function PersistentIsMarkedForDeletion(APersistent: TPersistent): boolean;
|
||||
function GetSelectedComponentClass: TRegisteredComponent;
|
||||
Procedure NudgeControl(DiffX, DiffY: Integer);
|
||||
Procedure NudgeSize(DiffX, DiffY: Integer);
|
||||
@ -179,7 +179,7 @@ type
|
||||
procedure DoShowTabOrderEditor;
|
||||
procedure DoShowChangeClassDialog;
|
||||
procedure GiveComponentsNames;
|
||||
procedure NotifyComponentAdded(AComponent: TComponent);
|
||||
procedure NotifyPersistentAdded(APersistent: TPersistent);
|
||||
|
||||
// popup menu
|
||||
procedure BuildPopupMenu;
|
||||
@ -239,7 +239,7 @@ type
|
||||
function IsDesignMsg(Sender: TControl;
|
||||
var TheMessage: TLMessage): Boolean; override;
|
||||
function UniqueName(const BaseName: string): string; override;
|
||||
Procedure RemoveComponentAndChilds(AComponent: TComponent);
|
||||
Procedure RemovePersistentAndChilds(APersistent: TPersistent);
|
||||
procedure Notification(AComponent: TComponent;
|
||||
Operation: TOperation); override;
|
||||
procedure ValidateRename(AComponent: TComponent;
|
||||
@ -261,10 +261,10 @@ type
|
||||
property LookupRoot: TComponent read FLookupRoot;
|
||||
property OnActivated: TNotifyEvent read FOnActivated write FOnActivated;
|
||||
property OnCloseQuery: TNotifyEvent read FOnCloseQuery write FOnCloseQuery;
|
||||
property OnComponentAdded: TOnComponentAdded
|
||||
read FOnComponentAdded write FOnComponentAdded;
|
||||
property OnComponentDeleted: TOnComponentDeleted
|
||||
read FOnComponentDeleted write FOnComponentDeleted;
|
||||
property OnPersistentAdded: TOnPersistentAdded
|
||||
read FOnPersistentAdded write FOnPersistentAdded;
|
||||
property OnPersistentDeleted: TOnPersistentDeleted
|
||||
read FOnPersistentDeleted write FOnPersistentDeleted;
|
||||
property OnGetNonVisualCompIconCanvas: TOnGetNonVisualCompIconCanvas
|
||||
read FOnGetNonVisualCompIconCanvas
|
||||
write FOnGetNonVisualCompIconCanvas;
|
||||
@ -278,8 +278,8 @@ type
|
||||
write FOnPasteComponent;
|
||||
property OnPropertiesChanged: TNotifyEvent
|
||||
read FOnPropertiesChanged write FOnPropertiesChanged;
|
||||
property OnRemoveComponent: TOnRemoveComponent
|
||||
read FOnRemoveComponent write FOnRemoveComponent;
|
||||
property OnRemovePersistent: TOnRemovePersistent
|
||||
read FOnRemovePersistent write FOnRemovePersistent;
|
||||
property OnRenameComponent: TOnRenameComponent
|
||||
read FOnRenameComponent write FOnRenameComponent;
|
||||
property OnSetDesigning: TOnSetDesigning
|
||||
@ -338,14 +338,15 @@ begin
|
||||
|
||||
DDC:=TDesignerDeviceContext.Create;
|
||||
LastFormCursor:=crDefault;
|
||||
DeletingComponents:=TList.Create;
|
||||
IgnoreDeletingComponents:=TList.Create;
|
||||
DeletingPersistent:=TList.Create;
|
||||
IgnoreDeletingPersistent:=TList.Create;
|
||||
end;
|
||||
|
||||
procedure TDesigner.DeleteFormAndFree;
|
||||
begin
|
||||
Include(FFlags,dfDestroyingForm);
|
||||
TheFormEditor.DeleteControl(FLookupRoot,true);
|
||||
if FLookupRoot is TComponent then
|
||||
TheFormEditor.DeleteComponent(FLookupRoot,true);
|
||||
Free;
|
||||
end;
|
||||
|
||||
@ -357,8 +358,8 @@ Begin
|
||||
FHintWIndow.Free;
|
||||
FHintTimer.Free;
|
||||
DDC.Free;
|
||||
DeletingComponents.Free;
|
||||
IgnoreDeletingComponents.Free;
|
||||
DeletingPersistent.Free;
|
||||
IgnoreDeletingPersistent.Free;
|
||||
Inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -392,11 +393,11 @@ begin
|
||||
end;
|
||||
i:=ControlSelection.Count-1;
|
||||
while (i>=0)
|
||||
and ((ControlSelection[i].ParentInSelection)
|
||||
or (not ControlSelection[i].IsTControl)
|
||||
or (TControl(ControlSelection[i].Component).Parent=nil)) do dec(i);
|
||||
and ( (ControlSelection[i].ParentInSelection)
|
||||
or (not ControlSelection[i].IsTControl)
|
||||
or (TControl(ControlSelection[i].Persistent).Parent=nil)) do dec(i);
|
||||
if i>=0 then
|
||||
SelectOnlyThisComponent(TControl(ControlSelection[i].Component).Parent);
|
||||
SelectOnlyThisComponent(TControl(ControlSelection[i].Persistent).Parent);
|
||||
end;
|
||||
|
||||
function TDesigner.DoCopySelectionToClipboard: boolean;
|
||||
@ -418,7 +419,7 @@ function TDesigner.DoCopySelectionToClipboard: boolean;
|
||||
end;
|
||||
|
||||
// check if not the top level component is selected
|
||||
CurParent:=TControl(ControlSelection[i].Component).Parent;
|
||||
CurParent:=TControl(ControlSelection[i].Persistent).Parent;
|
||||
if CurParent=nil then begin
|
||||
MessageDlg('Can not copy top level component.',
|
||||
'Copying a whole form is not implemented.',
|
||||
@ -450,12 +451,14 @@ function TDesigner.DoCopySelectionToClipboard: boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
for i:=0 to ControlSelection.Count-1 do begin
|
||||
if not ControlSelection[i].IsTComponent then continue;
|
||||
|
||||
BinCompStream:=TMemoryStream.Create;
|
||||
TxtCompStream:=TMemoryStream.Create;
|
||||
try
|
||||
// write component binary stream
|
||||
try
|
||||
CurComponent:=ControlSelection[i].Component;
|
||||
CurComponent:=TComponent(ControlSelection[i].Persistent);
|
||||
|
||||
Driver := TBinaryObjectWriter.Create(BinCompStream, 4096);
|
||||
Try
|
||||
@ -512,7 +515,7 @@ var
|
||||
AllComponentText: string;
|
||||
begin
|
||||
Result:=false;
|
||||
if ControlSelection.Count=0 then exit;
|
||||
if (ControlSelection.Count=0) then exit;
|
||||
|
||||
// Because controls will be pasted on a single parent,
|
||||
// unselect all controls, that do not have the same parent
|
||||
@ -562,11 +565,11 @@ var
|
||||
if PasteParent<>nil then exit;
|
||||
|
||||
for i:=0 to ControlSelection.Count-1 do begin
|
||||
if (ControlSelection[i].Component is TWinControl)
|
||||
if (ControlSelection[i].IsTWinControl)
|
||||
and (csAcceptsControls in
|
||||
TWinControl(ControlSelection[i].Component).ControlStyle)
|
||||
TWinControl(ControlSelection[i].Persistent).ControlStyle)
|
||||
and (not ControlSelection[i].ParentInSelection) then begin
|
||||
PasteParent:=TWinControl(ControlSelection[i].Component);
|
||||
PasteParent:=TWinControl(ControlSelection[i].Persistent);
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
@ -642,7 +645,7 @@ var
|
||||
// set new nice bounds
|
||||
FindUniquePosition(NewComponent);
|
||||
// finish adding component
|
||||
NotifyComponentAdded(NewComponent);
|
||||
NotifyPersistentAdded(NewComponent);
|
||||
Modified;
|
||||
end;
|
||||
|
||||
@ -718,7 +721,7 @@ procedure TDesigner.DoShowChangeClassDialog;
|
||||
begin
|
||||
if (ControlSelection.Count=1) and (not ControlSelection.LookupRootSelected)
|
||||
then
|
||||
ShowChangeClassDialog(ControlSelection[0].Component);
|
||||
ShowChangeClassDialog(ControlSelection[0].Persistent);
|
||||
end;
|
||||
|
||||
procedure TDesigner.GiveComponentsNames;
|
||||
@ -734,12 +737,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDesigner.NotifyComponentAdded(AComponent: TComponent);
|
||||
procedure TDesigner.NotifyPersistentAdded(APersistent: TPersistent);
|
||||
begin
|
||||
try
|
||||
GiveComponentsNames;
|
||||
if Assigned(FOnComponentAdded) then
|
||||
FOnComponentAdded(Self,AComponent,nil);
|
||||
if Assigned(FOnPersistentAdded) then
|
||||
FOnPersistentAdded(Self,APersistent,nil);
|
||||
except
|
||||
on E: Exception do
|
||||
MessageDlg('Error:',E.Message,mtError,[mbOk],0);
|
||||
@ -748,7 +751,7 @@ end;
|
||||
|
||||
procedure TDesigner.SelectOnlyThisComponent(AComponent:TComponent);
|
||||
begin
|
||||
ControlSelection.AssignComponent(AComponent);
|
||||
ControlSelection.AssignPersistent(AComponent);
|
||||
end;
|
||||
|
||||
procedure TDesigner.CopySelection;
|
||||
@ -759,7 +762,7 @@ end;
|
||||
procedure TDesigner.CutSelection;
|
||||
begin
|
||||
if DoCopySelectionToClipboard then
|
||||
DoDeleteSelectedComponents;
|
||||
DoDeleteSelectedPersistents;
|
||||
end;
|
||||
|
||||
function TDesigner.CanPaste: Boolean;
|
||||
@ -776,7 +779,7 @@ end;
|
||||
|
||||
procedure TDesigner.DeleteSelection;
|
||||
begin
|
||||
DoDeleteSelectedComponents;
|
||||
DoDeleteSelectedPersistents;
|
||||
end;
|
||||
|
||||
function TDesigner.InvokeComponentEditor(AComponent: TComponent;
|
||||
@ -822,16 +825,16 @@ begin
|
||||
case Command of
|
||||
|
||||
ecSelectParentComponent:
|
||||
SelectParentOfSelection;
|
||||
if not ControlSelection.OnlyInvisiblePersistensSelected then
|
||||
SelectParentOfSelection;
|
||||
|
||||
ecCopyComponents:
|
||||
CopySelection;
|
||||
if not ControlSelection.OnlyInvisiblePersistensSelected then
|
||||
CopySelection;
|
||||
|
||||
ecCutComponents:
|
||||
begin
|
||||
CopySelection;
|
||||
DeleteSelection;
|
||||
end;
|
||||
if not ControlSelection.OnlyInvisiblePersistensSelected then
|
||||
CutSelection;
|
||||
|
||||
ecPasteComponents:
|
||||
PasteSelection;
|
||||
@ -1091,7 +1094,7 @@ Begin
|
||||
|
||||
if (CompIndex<0) then begin
|
||||
// select only this component
|
||||
ControlSelection.AssignComponent(MouseDownComponent);
|
||||
ControlSelection.AssignPersistent(MouseDownComponent);
|
||||
end else
|
||||
// sync with the interface
|
||||
ControlSelection.UpdateBounds;
|
||||
@ -1181,7 +1184,7 @@ var
|
||||
ParentCI:=TComponentInterface(TheFormEditor.FindComponent(NewParent));
|
||||
if not Assigned(ParentCI) then exit;
|
||||
|
||||
if not PropertyEditorHook.BeforeAddComponent(Self,
|
||||
if not PropertyEditorHook.BeforeAddPersistent(Self,
|
||||
SelectedCompClass.ComponentClass,NewParent)
|
||||
then begin
|
||||
writeln('TDesigner.AddComponent ',
|
||||
@ -1220,7 +1223,7 @@ var
|
||||
FOnSetDesigning(Self,NewComponent,True);
|
||||
|
||||
// tell IDE about the new component (e.g. add it to the source)
|
||||
NotifyComponentAdded(NewComponent);
|
||||
NotifyPersistentAdded(NewComponent);
|
||||
|
||||
// creation completed
|
||||
// -> select new component
|
||||
@ -1281,7 +1284,7 @@ var
|
||||
begin
|
||||
if (not (ssShift in Shift)) then begin
|
||||
// select only the mouse down component
|
||||
ControlSelection.AssignComponent(MouseDownComponent);
|
||||
ControlSelection.AssignPersistent(MouseDownComponent);
|
||||
if (MouseDownClickCount=2)
|
||||
and (ControlSelection.SelectionForm=Form) then begin
|
||||
// Double Click -> invoke 'Edit' of the component editor
|
||||
@ -1516,7 +1519,8 @@ Begin
|
||||
Handled:=true;
|
||||
case TheMessage.CharCode of
|
||||
VK_DELETE:
|
||||
DoDeleteSelectedComponents;
|
||||
if not ControlSelection.OnlyInvisiblePersistensSelected then
|
||||
DoDeleteSelectedPersistents;
|
||||
|
||||
VK_UP:
|
||||
if (ssCtrl in Shift) then
|
||||
@ -1561,10 +1565,10 @@ Begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TDesigner.DoDeleteSelectedComponents;
|
||||
procedure TDesigner.DoDeleteSelectedPersistents;
|
||||
var
|
||||
i: integer;
|
||||
AComponent: TComponent;
|
||||
APersistent: TPersistent;
|
||||
begin
|
||||
if (ControlSelection.Count=0) or (ControlSelection.SelectionForm<>Form) then
|
||||
exit;
|
||||
@ -1577,71 +1581,73 @@ begin
|
||||
end;
|
||||
// mark selected components for deletion
|
||||
for i:=0 to ControlSelection.Count-1 do
|
||||
MarkComponentForDeletion(ControlSelection[i].Component);
|
||||
MarkPersistentForDeletion(ControlSelection[i].Persistent);
|
||||
// clear selection by selecting the LookupRoot
|
||||
SelectOnlyThisComponent(FLookupRoot);
|
||||
// delete marked components
|
||||
Include(FFlags,dfDeleting);
|
||||
if DeletingComponents.Count=0 then exit;
|
||||
while DeletingComponents.Count>0 do begin
|
||||
AComponent:=TComponent(DeletingComponents[DeletingComponents.Count-1]);
|
||||
if DeletingPersistent.Count=0 then exit;
|
||||
while DeletingPersistent.Count>0 do begin
|
||||
APersistent:=TPersistent(DeletingPersistent[DeletingPersistent.Count-1]);
|
||||
//writeln('TDesigner.DoDeleteSelectedComponents A ',AComponent.Name,':',AComponent.ClassName,' ',HexStr(Cardinal(AComponent),8));
|
||||
RemoveComponentAndChilds(AComponent);
|
||||
//writeln('TDesigner.DoDeleteSelectedComponents B ',DeletingComponents.IndexOf(AComponent));
|
||||
RemovePersistentAndChilds(APersistent);
|
||||
//writeln('TDesigner.DoDeleteSelectedComponents B ',DeletingPersistent.IndexOf(AComponent));
|
||||
end;
|
||||
IgnoreDeletingComponents.Clear;
|
||||
IgnoreDeletingPersistent.Clear;
|
||||
Exclude(FFlags,dfDeleting);
|
||||
Modified;
|
||||
end;
|
||||
|
||||
procedure TDesigner.DoDeleteComponent(AComponent: TComponent;
|
||||
FreeComponent: boolean);
|
||||
procedure TDesigner.DoDeletePersistent(APersistent: TPersistent;
|
||||
FreeIt: boolean);
|
||||
var
|
||||
Hook: TPropertyEditorHook;
|
||||
begin
|
||||
//writeln('TDesigner.DoDeleteComponent A ',AComponent.Name,':',AComponent.ClassName,' ',HexStr(Cardinal(AComponent),8));
|
||||
PopupMenuComponentEditor:=nil;
|
||||
// unselect component
|
||||
ControlSelection.Remove(AComponent);
|
||||
if TheFormEditor.FindComponent(AComponent)=nil then begin
|
||||
ControlSelection.Remove(APersistent);
|
||||
if (APersistent is TComponent)
|
||||
and (TheFormEditor.FindComponent(TComponent(APersistent))=nil) then begin
|
||||
// thsi component is currently in the process of deletion or the component
|
||||
// was not properly created
|
||||
// -> do not call handlers and simply get rid of the rubbish
|
||||
//writeln('TDesigner.DoDeleteComponent UNKNOWN ',AComponent.Name,':',AComponent.ClassName,' ',HexStr(Cardinal(AComponent),8));
|
||||
if FreeComponent then
|
||||
AComponent.Free;
|
||||
if FreeIt then
|
||||
APersistent.Free;
|
||||
// unmark component
|
||||
DeletingComponents.Remove(AComponent);
|
||||
IgnoreDeletingComponents.Remove(AComponent);
|
||||
DeletingPersistent.Remove(APersistent);
|
||||
IgnoreDeletingPersistent.Remove(APersistent);
|
||||
exit;
|
||||
end;
|
||||
// call RemoveComponent handler
|
||||
if Assigned(FOnRemoveComponent) then
|
||||
FOnRemoveComponent(Self,AComponent);
|
||||
if Assigned(FOnRemovePersistent) then
|
||||
FOnRemovePersistent(Self,APersistent);
|
||||
// call component deleting handlers
|
||||
Hook:=GetPropertyEditorHook;
|
||||
if Hook<>nil then
|
||||
Hook.ComponentDeleting(AComponent);
|
||||
Hook.PersistentDeleting(APersistent);
|
||||
// delete component
|
||||
TheFormEditor.DeleteControl(AComponent,FreeComponent);
|
||||
if APersistent is TComponent then
|
||||
TheFormEditor.DeleteComponent(TComponent(APersistent),FreeIt);
|
||||
// unmark component
|
||||
DeletingComponents.Remove(AComponent);
|
||||
IgnoreDeletingComponents.Remove(AComponent);
|
||||
DeletingPersistent.Remove(APersistent);
|
||||
IgnoreDeletingPersistent.Remove(APersistent);
|
||||
// call ComponentDeleted handler
|
||||
if Assigned(FOnComponentDeleted) then
|
||||
FOnComponentDeleted(Self,AComponent);
|
||||
if Assigned(FOnPersistentDeleted) then
|
||||
FOnPersistentDeleted(Self,APersistent);
|
||||
end;
|
||||
|
||||
procedure TDesigner.MarkComponentForDeletion(AComponent: TComponent);
|
||||
procedure TDesigner.MarkPersistentForDeletion(APersistent: TPersistent);
|
||||
begin
|
||||
if (not ComponentIsMarkedForDeletion(AComponent)) then
|
||||
DeletingComponents.Add(AComponent);
|
||||
if (not PersistentIsMarkedForDeletion(APersistent)) then
|
||||
DeletingPersistent.Add(APersistent);
|
||||
end;
|
||||
|
||||
function TDesigner.ComponentIsMarkedForDeletion(AComponent: TComponent
|
||||
function TDesigner.PersistentIsMarkedForDeletion(APersistent: TPersistent
|
||||
): boolean;
|
||||
begin
|
||||
Result:=(DeletingComponents.IndexOf(AComponent)>=0);
|
||||
Result:=(DeletingPersistent.IndexOf(APersistent)>=0);
|
||||
end;
|
||||
|
||||
function TDesigner.GetSelectedComponentClass: TRegisteredComponent;
|
||||
@ -1691,28 +1697,28 @@ Begin
|
||||
if Assigned(FOnModified) then FOnModified(Self);
|
||||
end;
|
||||
|
||||
Procedure TDesigner.RemoveComponentAndChilds(AComponent :TComponent);
|
||||
Procedure TDesigner.RemovePersistentAndChilds(APersistent: TPersistent);
|
||||
var
|
||||
i: integer;
|
||||
AWinControl: TWinControl;
|
||||
ChildControl: TControl;
|
||||
Begin
|
||||
{$IFDEF VerboseDesigner}
|
||||
Writeln('[TDesigner.RemoveComponentAndChilds] ',AComponent.Name,':',AComponent.ClassName,' ',HexStr(Cardinal(AComponent),8));
|
||||
Writeln('[TDesigner.RemovePersistentAndChilds] ',dbgsName(APersistent),' ',HexStr(Cardinal(APersistent),8));
|
||||
{$ENDIF}
|
||||
if (AComponent=FLookupRoot) or (AComponent=Form)
|
||||
or (IgnoreDeletingComponents.IndexOf(AComponent)>=0)
|
||||
if (APersistent=FLookupRoot) or (APersistent=Form)
|
||||
or (IgnoreDeletingPersistent.IndexOf(APersistent)>=0)
|
||||
then exit;
|
||||
// remove all child controls owned by the LookupRoot
|
||||
if (AComponent is TWinControl) then begin
|
||||
AWinControl:=TWinControl(AComponent);
|
||||
if (APersistent is TWinControl) then begin
|
||||
AWinControl:=TWinControl(APersistent);
|
||||
i:=AWinControl.ControlCount-1;
|
||||
while (i>=0) do begin
|
||||
ChildControl:=AWinControl.Controls[i];
|
||||
if (ChildControl.Owner=FLookupRoot)
|
||||
and (IgnoreDeletingComponents.IndexOf(ChildControl)<0) then begin
|
||||
and (IgnoreDeletingPersistent.IndexOf(ChildControl)<0) then begin
|
||||
//Writeln('[TDesigner.RemoveComponentAndChilds] B ',AComponent.Name,':',AComponent.ClassName,' ',HexStr(Cardinal(AComponent),8),' Child=',ChildControl.Name,':',ChildControl.ClassName,' i=',i);
|
||||
RemoveComponentAndChilds(ChildControl);
|
||||
RemovePersistentAndChilds(ChildControl);
|
||||
// the component list of the form has changed
|
||||
// -> restart the search
|
||||
i:=AWinControl.ControlCount-1;
|
||||
@ -1722,9 +1728,9 @@ Begin
|
||||
end;
|
||||
// remove component
|
||||
{$IFDEF VerboseDesigner}
|
||||
Writeln('[TDesigner.RemoveComponentAndChilds] C ',AComponent.Name,':',AComponent.ClassName);
|
||||
Writeln('[TDesigner.RemovePersistentAndChilds] C ',dbgsName(APersistent));
|
||||
{$ENDIF}
|
||||
DoDeleteComponent(AComponent,true);
|
||||
DoDeletePersistent(APersistent,true);
|
||||
end;
|
||||
|
||||
procedure TDesigner.Notification(AComponent: TComponent; Operation: TOperation);
|
||||
@ -1736,7 +1742,7 @@ Begin
|
||||
if dfDeleting in FFlags then begin
|
||||
// a component has auto created a new component during deletion
|
||||
// -> ignore the new component
|
||||
IgnoreDeletingComponents.Add(AComponent);
|
||||
IgnoreDeletingPersistent.Add(AComponent);
|
||||
end;
|
||||
end
|
||||
else
|
||||
@ -1745,7 +1751,7 @@ Begin
|
||||
writeln('[TDesigner.Notification] opRemove ',
|
||||
AComponent.Name,':',AComponent.ClassName);
|
||||
{$ENDIF}
|
||||
DoDeleteComponent(AComponent,false);
|
||||
DoDeletePersistent(AComponent,false);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1878,7 +1884,7 @@ end;
|
||||
|
||||
procedure TDesigner.OnDeleteSelectionMenuClick(Sender: TObject);
|
||||
begin
|
||||
DoDeleteSelectedComponents;
|
||||
DoDeleteSelectedPersistents;
|
||||
end;
|
||||
|
||||
procedure TDesigner.OnChangeClassMenuClick(Sender: TObject);
|
||||
@ -2115,8 +2121,10 @@ function TDesigner.GetComponentEditorForSelection: TBaseComponentEditor;
|
||||
begin
|
||||
Result:=nil;
|
||||
if (ControlSelection.Count<>1)
|
||||
or (ControlSelection.SelectionForm<>Form) then exit;
|
||||
Result:=TheFormEditor.GetComponentEditor(ControlSelection[0].Component);
|
||||
or (ControlSelection.SelectionForm<>Form)
|
||||
or (not ControlSelection[0].IsTComponent) then exit;
|
||||
Result:=
|
||||
TheFormEditor.GetComponentEditor(TComponent(ControlSelection[0].Persistent));
|
||||
end;
|
||||
|
||||
procedure TDesigner.AddComponentEditorMenuItems(
|
||||
@ -2198,17 +2206,20 @@ procedure TDesigner.BuildPopupMenu;
|
||||
var
|
||||
ControlSelIsNotEmpty,
|
||||
LookupRootIsSelected,
|
||||
OnlyNonVisualCompsAreSelected,
|
||||
OnlyNonVisualsAreSelected,
|
||||
CompsAreSelected: boolean;
|
||||
SelectionVisible: Boolean;
|
||||
begin
|
||||
if FPopupMenu<>nil then FPopupMenu.Free;
|
||||
|
||||
ControlSelIsNotEmpty:=(ControlSelection.Count>0)
|
||||
and (ControlSelection.SelectionForm=Form);
|
||||
LookupRootIsSelected:=ControlSelection.LookupRootSelected;
|
||||
OnlyNonVisualCompsAreSelected:=
|
||||
ControlSelection.OnlyNonVisualComponentsSelected;
|
||||
CompsAreSelected:=ControlSelIsNotEmpty and not LookupRootIsSelected;
|
||||
OnlyNonVisualsAreSelected:=
|
||||
ControlSelection.OnlyNonVisualPersistentsSelected;
|
||||
SelectionVisible:=not ControlSelection.OnlyInvisiblePersistensSelected;
|
||||
CompsAreSelected:=ControlSelIsNotEmpty and SelectionVisible
|
||||
and not LookupRootIsSelected;
|
||||
|
||||
FPopupMenu:=TPopupMenu.Create(nil);
|
||||
|
||||
@ -2243,7 +2254,7 @@ begin
|
||||
with FScaleMenuItem do begin
|
||||
Caption := fdmScaleWord;
|
||||
OnClick := @OnScalePopupMenuClick;
|
||||
Enabled := CompsAreSelected and not OnlyNonVisualCompsAreSelected;
|
||||
Enabled := CompsAreSelected and not OnlyNonVisualsAreSelected;
|
||||
end;
|
||||
FPopupMenu.Items.Add(FScaleMenuItem);
|
||||
|
||||
@ -2251,7 +2262,7 @@ begin
|
||||
with FSizeMenuItem do begin
|
||||
Caption := fdmSizeWord;
|
||||
OnClick := @OnSizePopupMenuClick;
|
||||
Enabled := CompsAreSelected and not OnlyNonVisualCompsAreSelected;
|
||||
Enabled := CompsAreSelected and not OnlyNonVisualsAreSelected;
|
||||
end;
|
||||
FPopupMenu.Items.Add(FSizeMenuItem);
|
||||
|
||||
@ -2440,22 +2451,18 @@ begin
|
||||
end;
|
||||
|
||||
procedure TDesigner.OnBringToFrontMenuClick(Sender: TObject);
|
||||
var AComponent : TComponent;
|
||||
begin
|
||||
if ControlSelection.Count = 1 then begin
|
||||
AComponent:= ControlSelection.Items[0].Component;
|
||||
if AComponent is TControl then
|
||||
TControl(AComponent).BringToFront;
|
||||
if (ControlSelection.Count = 1)
|
||||
and (ControlSelection[0].IsTControl) then begin
|
||||
TControl(ControlSelection[0].Persistent).BringToFront;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDesigner.OnSendToBackMenuClick(Sender: TObject);
|
||||
var AComponent : TComponent;
|
||||
begin
|
||||
if ControlSelection.Count = 1 then begin
|
||||
AComponent:= ControlSelection.Items[0].Component;
|
||||
if AComponent is TControl then
|
||||
TControl(AComponent).SendToBack;
|
||||
if (ControlSelection.Count = 1)
|
||||
and (ControlSelection[0].IsTControl) then begin
|
||||
TControl(ControlSelection[0].Persistent).SendToBack;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -369,7 +369,7 @@ begin
|
||||
firstmenuitem.Caption:='New Item1';
|
||||
firstmenuitem.Name:=GetDesigner.CreateUniqueComponentName(firstmenuitem.ClassName);
|
||||
fMenu.Items.Insert(0, firstmenuitem);
|
||||
GetDesigner.PropertyEditorHook.ComponentAdded(firstmenuitem, true);
|
||||
GetDesigner.PropertyEditorHook.PersistentAdded(firstmenuitem, true);
|
||||
GetDesigner.Modified;
|
||||
end;
|
||||
|
||||
@ -1765,7 +1765,7 @@ begin
|
||||
// code from Mattias (one of mail he sent me)
|
||||
temp_menuitem.Name:=GetDesigner.CreateUniqueComponentName(temp_menuitem.ClassName);
|
||||
MenuItem.Insert(index_sequence[Ind] + 1, temp_menuitem);
|
||||
GetDesigner.PropertyEditorHook.ComponentAdded(temp_menuitem, true);
|
||||
GetDesigner.PropertyEditorHook.PersistentAdded(temp_menuitem, true);
|
||||
GetDesigner.Modified;
|
||||
|
||||
end else
|
||||
@ -1783,7 +1783,7 @@ begin
|
||||
// code from Mattias (one of mail he sent me)
|
||||
temp_menuitem.Name:=GetDesigner.CreateUniqueComponentName(temp_menuitem.ClassName);
|
||||
MenuItem.Insert(index_sequence[Ind] - 1, temp_menuitem);
|
||||
GetDesigner.PropertyEditorHook.ComponentAdded(temp_menuitem, true);
|
||||
GetDesigner.PropertyEditorHook.PersistentAdded(temp_menuitem, true);
|
||||
GetDesigner.Modified;
|
||||
end else
|
||||
begin
|
||||
@ -1800,7 +1800,7 @@ begin
|
||||
// code from Mattias (one of mail he sent me)
|
||||
temp_menuitem.Name:=GetDesigner.CreateUniqueComponentName(temp_menuitem.ClassName);
|
||||
MenuItem[index_sequence[Ind]].Add(temp_menuitem);
|
||||
GetDesigner.PropertyEditorHook.ComponentAdded(temp_menuitem, true);
|
||||
GetDesigner.PropertyEditorHook.PersistentAdded(temp_menuitem, true);
|
||||
GetDesigner.Modified;
|
||||
end else
|
||||
UpdateMenu(MenuItem.Items[index_sequence[Ind]], DesignerMenuItem, Ind + 1, TheAction);
|
||||
|
@ -49,8 +49,8 @@ type
|
||||
fDesigner: TComponentEditorDesigner;
|
||||
List_menus: TListBox;
|
||||
Label_menus: TLabel;
|
||||
procedure OnComponentDeleting(AComponent: TComponent);
|
||||
procedure OnComponentAdded(AComponent: TComponent; Select: boolean);
|
||||
procedure OnPersistentDeleting(AComponent: TComponent);
|
||||
procedure OnPersistentAdded(AComponent: TComponent; Select: boolean);
|
||||
procedure CreateDesignerMenu;
|
||||
procedure UpdateListOfMenus;
|
||||
public
|
||||
@ -115,7 +115,7 @@ end;
|
||||
|
||||
{ TMainMenuEditorForm }
|
||||
|
||||
procedure TMainMenuEditorForm.OnComponentDeleting(AComponent: TComponent);
|
||||
procedure TMainMenuEditorForm.OnPersistentDeleting(AComponent: TComponent);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
@ -124,7 +124,7 @@ begin
|
||||
if i>=0 then List_menus.Items.Delete(i);
|
||||
end;
|
||||
|
||||
procedure TMainMenuEditorForm.OnComponentAdded(AComponent: TComponent;
|
||||
procedure TMainMenuEditorForm.OnPersistentAdded(AComponent: TComponent;
|
||||
Select: boolean);
|
||||
begin
|
||||
if AComponent is TMenu then
|
||||
@ -241,8 +241,8 @@ begin
|
||||
UpdateListOfMenus;
|
||||
CreateDesignerMenu;
|
||||
|
||||
GlobalDesignHook.AddHandlerComponentDeleting(@OnComponentDeleting);
|
||||
GlobalDesignHook.AddHandlerComponentAdded(@OnComponentAdded);
|
||||
GlobalDesignHook.AddHandlerPersistentDeleting(@OnPersistentDeleting);
|
||||
GlobalDesignHook.AddHandlerPersistentAdded(@OnPersistentAdded);
|
||||
end;
|
||||
|
||||
destructor TMainMenuEditorForm.Destroy;
|
||||
|
@ -141,7 +141,7 @@ each control that's dropped onto the form
|
||||
destructor Destroy; override;
|
||||
|
||||
Function AddSelected(Value : TComponent) : Integer;
|
||||
Procedure DeleteControl(AComponent: TComponent; FreeComponent: boolean);
|
||||
Procedure DeleteComponent(AComponent: TComponent; FreeComponent: boolean);
|
||||
Function FindComponentByName(const Name : ShortString) : TIComponentInterface; override;
|
||||
Function FindComponent(AComponent: TComponent): TIComponentInterface; override;
|
||||
|
||||
@ -692,7 +692,7 @@ Begin
|
||||
Obj_Inspector.Selection := FSelection;
|
||||
end;
|
||||
|
||||
Procedure TCustomFormEditor.DeleteControl(AComponent: TComponent;
|
||||
Procedure TCustomFormEditor.DeleteComponent(AComponent: TComponent;
|
||||
FreeComponent: boolean);
|
||||
var
|
||||
Temp : TComponentInterface;
|
||||
@ -711,7 +711,7 @@ Begin
|
||||
if FreeComponent then begin
|
||||
i:=AComponent.ComponentCount-1;
|
||||
while i>=0 do begin
|
||||
DeleteControl(AComponent.Components[i],true);
|
||||
DeleteComponent(AComponent.Components[i],true);
|
||||
dec(i);
|
||||
if i>AComponent.ComponentCount-1 then
|
||||
i:=AComponent.ComponentCount-1;
|
||||
|
170
ide/main.pp
170
ide/main.pp
@ -300,33 +300,36 @@ type
|
||||
ATypeInfo:PTypeInfo): TMethod;
|
||||
procedure OnPropHookShowMethod(const AMethodName:ShortString);
|
||||
procedure OnPropHookRenameMethod(const CurName, NewName:ShortString);
|
||||
function OnPropHookBeforeAddComponent(Sender: TObject;
|
||||
AComponentClass: TComponentClass; AParent: TComponent): boolean;
|
||||
function OnPropHookBeforeAddPersistent(Sender: TObject;
|
||||
APersistentClass: TPersistentClass;
|
||||
AParent: TPersistent): boolean;
|
||||
procedure OnPropHookComponentRenamed(AComponent: TComponent);
|
||||
procedure OnPropHookComponentAdded(AComponent: TComponent; Select: boolean);
|
||||
procedure OnPropHookDeleteComponent(AComponent: TComponent);
|
||||
procedure OnPropHookPersistentAdded(APersistent: TPersistent;
|
||||
Select: boolean);
|
||||
procedure OnPropHookDeletePersistent(APersistent: TPersistent);
|
||||
|
||||
// designer events
|
||||
procedure OnDesignerGetSelectedComponentClass(Sender: TObject;
|
||||
var RegisteredComponent: TRegisteredComponent);
|
||||
procedure OnDesignerUnselectComponentClass(Sender: TObject);
|
||||
procedure OnDesignerSetDesigning(Sender: TObject; Component: TComponent;
|
||||
Value: boolean);
|
||||
Value: boolean);
|
||||
procedure OnDesignerShowOptions(Sender: TObject);
|
||||
procedure OnDesignerPasteComponent(Sender: TObject; LookupRoot: TComponent;
|
||||
TxtCompStream: TStream; ParentControl: TWinControl;
|
||||
var NewComponent: TComponent);
|
||||
TxtCompStream: TStream; ParentControl: TWinControl;
|
||||
var NewComponent: TComponent);
|
||||
procedure OnDesignerPropertiesChanged(Sender: TObject);
|
||||
procedure OnDesignerComponentAdded(Sender: TObject; AComponent: TComponent;
|
||||
AComponentClass: TRegisteredComponent);
|
||||
procedure OnDesignerComponentDeleted(Sender: TObject;
|
||||
AComponent: TComponent);
|
||||
procedure OnDesignerRemoveComponent(Sender: TObject; AComponent: TComponent);
|
||||
procedure OnDesignerPersistentAdded(Sender: TObject; APersistent: TPersistent;
|
||||
AComponentClass: TRegisteredComponent);
|
||||
procedure OnDesignerPersistentDeleted(Sender: TObject;
|
||||
APersistent: TPersistent);
|
||||
procedure OnDesignerRemovePersistent(Sender: TObject;
|
||||
APersistent: TPersistent);
|
||||
procedure OnDesignerModified(Sender: TObject);
|
||||
procedure OnDesignerActivated(Sender: TObject);
|
||||
procedure OnDesignerCloseQuery(Sender: TObject);
|
||||
procedure OnDesignerRenameComponent(ADesigner: TDesigner;
|
||||
AComponent: TComponent; const NewName: string);
|
||||
AComponent: TComponent; const NewName: string);
|
||||
|
||||
// control selection
|
||||
procedure OnControlSelectionChanged(Sender: TObject);
|
||||
@ -1229,9 +1232,9 @@ begin
|
||||
GlobalDesignHook.AddHandlerCreateMethod(@OnPropHookCreateMethod);
|
||||
GlobalDesignHook.AddHandlerShowMethod(@OnPropHookShowMethod);
|
||||
GlobalDesignHook.AddHandlerRenameMethod(@OnPropHookRenameMethod);
|
||||
GlobalDesignHook.AddHandlerBeforeAddComponent(@OnPropHookBeforeAddComponent);
|
||||
GlobalDesignHook.AddHandlerBeforeAddPersistent(@OnPropHookBeforeAddPersistent);
|
||||
GlobalDesignHook.AddHandlerComponentRenamed(@OnPropHookComponentRenamed);
|
||||
GlobalDesignHook.AddHandlerComponentAdded(@OnPropHookComponentAdded);
|
||||
GlobalDesignHook.AddHandlerPersistentAdded(@OnPropHookPersistentAdded);
|
||||
|
||||
ObjectInspector1.PropertyEditorHook:=GlobalDesignHook;
|
||||
EnvironmentOptions.IDEWindowLayoutList.Apply(ObjectInspector1,
|
||||
@ -2186,8 +2189,8 @@ Begin
|
||||
TheFormEditor := FormEditor1;
|
||||
OnActivated:=@OnDesignerActivated;
|
||||
OnCloseQuery:=@OnDesignerCloseQuery;
|
||||
OnComponentAdded:=@OnDesignerComponentAdded;
|
||||
OnComponentDeleted:=@OnDesignerComponentDeleted;
|
||||
OnPersistentAdded:=@OnDesignerPersistentAdded;
|
||||
OnPersistentDeleted:=@OnDesignerPersistentDeleted;
|
||||
OnGetNonVisualCompIconCanvas:=
|
||||
@TComponentPalette(IDEComponentPalette).OnGetNonVisualCompIconCanvas;
|
||||
OnGetSelectedComponentClass:=@OnDesignerGetSelectedComponentClass;
|
||||
@ -2195,7 +2198,7 @@ Begin
|
||||
OnPasteComponent:=@OnDesignerPasteComponent;
|
||||
OnProcessCommand:=@OnProcessIDECommand;
|
||||
OnPropertiesChanged:=@OnDesignerPropertiesChanged;
|
||||
OnRemoveComponent:=@OnDesignerRemoveComponent;
|
||||
OnRemovePersistent:=@OnDesignerRemovePersistent;
|
||||
OnRenameComponent:=@OnDesignerRenameComponent;
|
||||
OnSetDesigning:=@OnDesignerSetDesigning;
|
||||
OnShowOptions:=@OnDesignerShowOptions;
|
||||
@ -3789,7 +3792,7 @@ begin
|
||||
DesignerForm:=FormEditor1.GetDesignerForm(NewComponent);
|
||||
if not (ofProjectLoading in Flags) then begin
|
||||
GlobalDesignHook.LookupRoot := NewComponent;
|
||||
TheControlSelection.AssignComponent(NewComponent);
|
||||
TheControlSelection.AssignPersistent(NewComponent);
|
||||
end;
|
||||
FLastFormActivated:=DesignerForm;
|
||||
end;
|
||||
@ -7302,7 +7305,7 @@ begin
|
||||
ShowDesignerForm(AForm);
|
||||
if TheControlSelection.SelectionForm<>AForm then begin
|
||||
// select the new form (object inspector, formeditor, control selection)
|
||||
TheControlSelection.AssignComponent(ActiveUnitInfo.Component);
|
||||
TheControlSelection.AssignPersistent(ActiveUnitInfo.Component);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -8222,37 +8225,42 @@ begin
|
||||
ObjectInspector1.RefreshPropertyValues;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerComponentAdded(Sender: TObject;
|
||||
AComponent: TComponent; AComponentClass: TRegisteredComponent);
|
||||
procedure TMainIDE.OnDesignerPersistentAdded(Sender: TObject;
|
||||
APersistent: TPersistent; AComponentClass: TRegisteredComponent);
|
||||
var
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
ActiveSrcEdit: TSourceEditor;
|
||||
ADesigner: TDesigner;
|
||||
begin
|
||||
if not (Sender is TDesigner) then begin
|
||||
writeln('TMainIDE.OnDesignerComponentAdded ERROR: Sender.ClassName=',
|
||||
writeln('TMainIDE.OnDesignerPersistentAdded ERROR: Sender.ClassName=',
|
||||
Sender.ClassName);
|
||||
exit;
|
||||
end;
|
||||
if AComponentClass=nil then
|
||||
AComponentClass:=IDEComponentPalette.FindComponent(AComponent.ClassName);
|
||||
AComponentClass:=IDEComponentPalette.FindComponent(APersistent.ClassName);
|
||||
ADesigner:=TDesigner(Sender);
|
||||
BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo,[ctfSwitchToFormSource]);
|
||||
if not BeginCodeTool(ADesigner,ActiveSrcEdit,ActiveUnitInfo,
|
||||
[ctfSwitchToFormSource])
|
||||
then exit;
|
||||
|
||||
if AComponentClass<>nil then begin
|
||||
// add needed package to required packages
|
||||
PkgBoss.AddProjectRegCompDependency(Project1,AComponentClass);
|
||||
// add needed unit to source
|
||||
CodeToolBoss.AddUnitToMainUsesSection(ActiveUnitInfo.Source,
|
||||
AComponentClass.GetUnitName,'');
|
||||
ActiveUnitInfo.Modified:=true;
|
||||
// add component definitions to form source
|
||||
CodeToolBoss.CompleteComponent(ActiveUnitInfo.Source,ADesigner.LookupRoot);
|
||||
PkgBoss.AddProjectRegCompDependency(Project1,AComponentClass);
|
||||
// add needed unit to source
|
||||
CodeToolBoss.AddUnitToMainUsesSection(ActiveUnitInfo.Source,
|
||||
AComponentClass.GetUnitName,'');
|
||||
ActiveUnitInfo.Modified:=true;
|
||||
|
||||
// add component definitions to form source
|
||||
CodeToolBoss.CompleteComponent(ActiveUnitInfo.Source,ADesigner.LookupRoot);
|
||||
end;
|
||||
|
||||
ObjectInspector1.FillPersistentComboBox;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerComponentDeleted(Sender: TObject;
|
||||
AComponent: TComponent);
|
||||
procedure TMainIDE.OnDesignerPersistentDeleted(Sender: TObject;
|
||||
APersistent: TPersistent);
|
||||
var
|
||||
CurDesigner: TDesigner;
|
||||
begin
|
||||
@ -8261,8 +8269,8 @@ begin
|
||||
ObjectInspector1.FillPersistentComboBox;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerRemoveComponent(Sender: TObject;
|
||||
AComponent: TComponent);
|
||||
procedure TMainIDE.OnDesignerRemovePersistent(Sender: TObject;
|
||||
APersistent: TPersistent);
|
||||
var
|
||||
ActiveForm: TCustomForm;
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
@ -8273,8 +8281,8 @@ begin
|
||||
CurDesigner:=TDesigner(Sender);
|
||||
if dfDestroyingForm in CurDesigner.Flags then exit;
|
||||
|
||||
BeginCodeTool(CurDesigner,ActiveSrcEdit,ActiveUnitInfo,
|
||||
[ctfSwitchToFormSource]);
|
||||
if not BeginCodeTool(CurDesigner,ActiveSrcEdit,ActiveUnitInfo,
|
||||
[ctfSwitchToFormSource]) then exit;
|
||||
ActiveForm:=CurDesigner.Form;
|
||||
if ActiveForm=nil then
|
||||
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: TDesigner without a form');
|
||||
@ -8283,10 +8291,12 @@ begin
|
||||
if ActiveUnitInfo=nil then begin
|
||||
RaiseException('[TMainIDE.OnDesignerAddComponent] Error: form without source');
|
||||
end;
|
||||
// remove component definition from owner source
|
||||
OwnerClassName:=CurDesigner.LookupRoot.ClassName;
|
||||
CodeToolBoss.RemovePublishedVariable(ActiveUnitInfo.Source,OwnerClassName,
|
||||
AComponent.Name,false);
|
||||
if APersistent is TComponent then begin
|
||||
// remove component definition from owner source
|
||||
OwnerClassName:=CurDesigner.LookupRoot.ClassName;
|
||||
CodeToolBoss.RemovePublishedVariable(ActiveUnitInfo.Source,OwnerClassName,
|
||||
TComponent(APersistent).Name,false);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnDesignerModified(Sender: TObject);
|
||||
@ -8322,7 +8332,7 @@ begin
|
||||
|
||||
NewSelection:=TPersistentSelectionList.Create;
|
||||
for i:=0 to TheControlSelection.Count-1 do
|
||||
NewSelection.Add(TheControlSelection[i].Component);
|
||||
NewSelection.Add(TheControlSelection[i].Persistent);
|
||||
FormEditor1.Selection:=NewSelection;
|
||||
NewSelection.Free;
|
||||
{$IFDEF IDE_DEBUG}
|
||||
@ -10092,12 +10102,12 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainIDE.OnPropHookBeforeAddComponent(Sender: TObject;
|
||||
AComponentClass: TComponentClass; AParent: TComponent): boolean;
|
||||
function TMainIDE.OnPropHookBeforeAddPersistent(Sender: TObject;
|
||||
APersistentClass: TPersistentClass; AParent: TPersistent): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if (not (AParent is TControl))
|
||||
and (AComponentClass.InheritsFrom(TControl)) then begin
|
||||
and (APersistentClass.InheritsFrom(TControl)) then begin
|
||||
MessageDlg('Invalid parent',
|
||||
'A '+Parent.ClassName+' can not hold TControls.'#13
|
||||
+'You can only put non visual components on it.',
|
||||
@ -10116,54 +10126,65 @@ begin
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
procedure TMainIDE.OnPropHookComponentAdded(AComponent: TComponent;
|
||||
procedure TMainIDE.OnPropHookPersistentAdded(APersistent: TPersistent;
|
||||
Select: boolean);
|
||||
|
||||
This handler is called whenever a new component was added to a designed form
|
||||
and should be added to form source
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TMainIDE.OnPropHookComponentAdded(AComponent: TComponent;
|
||||
procedure TMainIDE.OnPropHookPersistentAdded(APersistent: TPersistent;
|
||||
Select: boolean);
|
||||
var
|
||||
ComponentClass: TRegisteredComponent;
|
||||
ADesigner: TIDesigner;
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
writeln('TMainIDE.OnPropHookComponentAdded A ',AComponent.Name,':',AComponent.ClassName);
|
||||
ComponentClass:=IDEComponentPalette.FindComponent(AComponent.ClassName);
|
||||
if ComponentClass=nil then begin
|
||||
writeln('TMainIDE.OnPropHookComponentAdded ',AComponent.ClassName,
|
||||
writeln('TMainIDE.OnPropHookPersistentAdded A ',dbgsName(APersistent));
|
||||
if APersistent is TComponent then
|
||||
AComponent:=TComponent(APersistent)
|
||||
else
|
||||
AComponent:=nil;
|
||||
ComponentClass:=IDEComponentPalette.FindComponent(APersistent.ClassName);
|
||||
if (ComponentClass=nil) and (AComponent<>nil) then begin
|
||||
writeln('TMainIDE.OnPropHookPersistentAdded ',APersistent.ClassName,
|
||||
' not registered');
|
||||
exit;
|
||||
end;
|
||||
// create unique name
|
||||
if AComponent.Name='' then
|
||||
AComponent.Name:=FormEditor1.CreateUniqueComponentName(AComponent);
|
||||
//writeln('TMainIDE.OnPropHookComponentAdded B ',AComponent.Name,':',AComponent.ClassName);
|
||||
// create component interface
|
||||
if FormEditor1.FindComponent(AComponent)=nil then
|
||||
FormEditor1.CreateComponentInterface(AComponent);
|
||||
// set component into design mode
|
||||
SetDesigning(AComponent,true);
|
||||
//writeln('TMainIDE.OnPropHookComponentAdded C ',AComponent.Name,':',AComponent.ClassName);
|
||||
// add to source
|
||||
ADesigner:=FindRootDesigner(AComponent);
|
||||
OnDesignerComponentAdded(ADesigner,AComponent,ComponentClass);
|
||||
//writeln('TMainIDE.OnPropHookComponentAdded D ',AComponent.Name,':',AComponent.ClassName,' ',Select);
|
||||
if AComponent<>nil then begin
|
||||
// create unique name
|
||||
if AComponent.Name='' then
|
||||
AComponent.Name:=FormEditor1.CreateUniqueComponentName(AComponent);
|
||||
//writeln('TMainIDE.OnPropHookPersistentAdded B ',AComponent.Name,':',AComponent.ClassName);
|
||||
// create component interface
|
||||
if FormEditor1.FindComponent(AComponent)=nil then
|
||||
FormEditor1.CreateComponentInterface(AComponent);
|
||||
// set component into design mode
|
||||
SetDesigning(AComponent,true);
|
||||
//writeln('TMainIDE.OnPropHookPersistentAdded C ',AComponent.Name,':',AComponent.ClassName);
|
||||
// add to source
|
||||
ADesigner:=FindRootDesigner(AComponent);
|
||||
end;
|
||||
OnDesignerPersistentAdded(ADesigner,APersistent,ComponentClass);
|
||||
//writeln('TMainIDE.OnPropHookPersistentAdded D ',AComponent.Name,':',AComponent.ClassName,' ',Select);
|
||||
// select component
|
||||
if Select then begin
|
||||
TheControlSelection.AssignComponent(AComponent);
|
||||
TheControlSelection.AssignPersistent(APersistent);
|
||||
end;
|
||||
writeln('TMainIDE.OnPropHookComponentAdded END ',AComponent.Name,':',AComponent.ClassName,' ',Select);
|
||||
writeln('TMainIDE.OnPropHookPersistentAdded END ',dbgsName(APersistent),' Select=',Select);
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnPropHookDeleteComponent(AComponent: TComponent);
|
||||
procedure TMainIDE.OnPropHookDeletePersistent(APersistent: TPersistent);
|
||||
var
|
||||
ADesigner: TDesigner;
|
||||
AComponent: TComponent;
|
||||
begin
|
||||
writeln('TMainIDE.OnPropHookDeleteComponent A ',AComponent.Name,':',AComponent.ClassName);
|
||||
ADesigner:=TDesigner(FindRootDesigner(AComponent));
|
||||
if ADesigner=nil then exit;
|
||||
ADesigner.RemoveComponentAndChilds(AComponent);
|
||||
writeln('TMainIDE.OnPropHookDeletePersistent A ',dbgsName(APersistent));
|
||||
if APersistent is TComponent then begin
|
||||
AComponent:=TComponent(APersistent);
|
||||
ADesigner:=TDesigner(FindRootDesigner(AComponent));
|
||||
if ADesigner=nil then exit;
|
||||
ADesigner.RemovePersistentAndChilds(AComponent);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainIDE.mnuEditCopyClicked(Sender: TObject);
|
||||
@ -10454,6 +10475,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.737 2004/07/24 11:23:55 mattias
|
||||
Designer can now handle TPersistent selections, TCollectionPropertyEditor basically working
|
||||
|
||||
Revision 1.736 2004/07/07 17:10:02 mattias
|
||||
added hint for unimplemented IDE directives for non pascal sources
|
||||
|
||||
|
@ -70,8 +70,8 @@ type
|
||||
FActionList: TActionList;
|
||||
FDesigner: TComponentEditorDesigner;
|
||||
protected
|
||||
procedure OnComponentDeleting(AComponent: TComponent);
|
||||
procedure OnComponentAdded(AComponent: TComponent; Select: boolean);
|
||||
procedure OnPersistentDeleting(APersistent: TPersistent);
|
||||
procedure OnPersistentAdded(APersistent: TPersistent; Select: boolean);
|
||||
procedure OnComponentRenamed(AComponent: TComponent);
|
||||
procedure CreateActionListEditor; // create form
|
||||
function GetSelectedAction: TContainedAction;
|
||||
@ -146,7 +146,7 @@ begin
|
||||
|
||||
NewAction.ActionList:=FActionList;
|
||||
|
||||
FDesigner.PropertyEditorHook.ComponentAdded(NewAction,true);
|
||||
FDesigner.PropertyEditorHook.PersistentAdded(NewAction,true);
|
||||
FDesigner.Modified;
|
||||
// writeln('Add done');
|
||||
end;
|
||||
@ -170,7 +170,7 @@ begin
|
||||
if assigned(OldAction) then
|
||||
begin
|
||||
try
|
||||
FDesigner.PropertyEditorHook.ComponentDeleting(OldAction);
|
||||
FDesigner.PropertyEditorHook.PersistentDeleting(OldAction);
|
||||
OldAction.Free;
|
||||
except
|
||||
on E: Exception do begin
|
||||
@ -222,13 +222,13 @@ begin
|
||||
FDesigner.SelectOnlyThisComponent(CurAction);
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.OnComponentDeleting(AComponent: TComponent);
|
||||
procedure TActionListEditor.OnPersistentDeleting(APersistent: TPersistent);
|
||||
var
|
||||
xIndex:Integer;
|
||||
begin
|
||||
if (AComponent is TAction) then
|
||||
if (APersistent is TAction) then
|
||||
begin
|
||||
xIndex:=lstActionName.Items.IndexOf(AComponent.Name);
|
||||
xIndex:=lstActionName.Items.IndexOf(TAction(APersistent).Name);
|
||||
if xIndex<0 then Exit; // action not showed in listbox (other category)
|
||||
lstActionName.Items.Delete(xIndex);
|
||||
if lstActionName.Items.Count=0 then
|
||||
@ -241,10 +241,10 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TActionListEditor.OnComponentAdded(AComponent: TComponent;
|
||||
procedure TActionListEditor.OnPersistentAdded(APersistent: TPersistent;
|
||||
Select: boolean);
|
||||
begin
|
||||
if (AComponent is TAction) then
|
||||
if (APersistent is TAction) then
|
||||
// ToDo: only set update flag and do not rebuild everything on every change
|
||||
FillCategories;
|
||||
end;
|
||||
@ -338,8 +338,8 @@ begin
|
||||
SetBounds(130,48, 65 ,17);
|
||||
end;
|
||||
|
||||
GlobalDesignHook.AddHandlerComponentDeleting(@OnComponentDeleting);
|
||||
GlobalDesignHook.AddHandlerComponentAdded(@OnComponentAdded);
|
||||
GlobalDesignHook.AddHandlerPersistentDeleting(@OnPersistentDeleting);
|
||||
GlobalDesignHook.AddHandlerPersistentAdded(@OnPersistentAdded);
|
||||
GlobalDesignHook.AddHandlerComponentRenamed(@OnComponentRenamed);
|
||||
end;
|
||||
|
||||
|
@ -570,7 +570,7 @@ begin
|
||||
NewPage.Caption:=NewName;
|
||||
NewPage.Name:=NewName;
|
||||
NoteBook.PageIndex:=Index;
|
||||
Hook.ComponentAdded(NewPage,true);
|
||||
Hook.PersistentAdded(NewPage,true);
|
||||
Modified;
|
||||
end;
|
||||
|
||||
@ -605,7 +605,7 @@ begin
|
||||
if (OldIndex>=0) and (OldIndex<Notebook.PageCount) then begin
|
||||
if not GetHook(Hook) then exit;
|
||||
PageComponent:=TComponent(NoteBook.PageList[OldIndex]);
|
||||
Hook.DeleteComponent(PageComponent);
|
||||
Hook.DeletePersistent(PageComponent);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -893,7 +893,7 @@ begin
|
||||
NewToolButton.Name:=NewName;
|
||||
NewToolButton.Style:=NewStyle;
|
||||
NewToolButton.Parent:=CurToolBar;
|
||||
Hook.ComponentAdded(NewToolButton,true);
|
||||
Hook.PersistentAdded(NewToolButton,true);
|
||||
Modified;
|
||||
end;
|
||||
|
||||
|
@ -1057,14 +1057,14 @@ type
|
||||
TPropHookGetComponentNames = procedure(TypeData:PTypeData;
|
||||
Proc:TGetStringProc) of object;
|
||||
TPropHookGetRootClassName = function:ShortString of object;
|
||||
TPropHookBeforeAddComponent = function(Sender: TObject;
|
||||
AComponentClass: TComponentClass;
|
||||
Parent: TComponent): boolean of object;
|
||||
TPropHookBeforeAddPersistent = function(Sender: TObject;
|
||||
APersistentClass: TPersistentClass;
|
||||
Parent: TPersistent): boolean of object;
|
||||
TPropHookComponentRenamed = procedure(AComponent: TComponent) of object;
|
||||
TPropHookComponentAdded = procedure(AComponent: TComponent; Select: boolean
|
||||
TPropHookPersistentAdded = procedure(APersistent: TPersistent; Select: boolean
|
||||
) of object;
|
||||
TPropHookComponentDeleting = procedure(AComponent: TComponent) of object;
|
||||
TPropHookDeleteComponent = procedure(var AComponent: TComponent) of object;
|
||||
TPropHookPersistentDeleting = procedure(APersistent: TPersistent) of object;
|
||||
TPropHookDeletePersistent = procedure(var APersistent: TPersistent) of object;
|
||||
TPropHookGetSelection = procedure(const ASelection: TPersistentSelectionList
|
||||
) of object;
|
||||
TPropHookSetSelection = procedure(const ASelection: TPersistentSelectionList
|
||||
@ -1097,12 +1097,12 @@ type
|
||||
htGetComponentNames,
|
||||
htGetRootClassName,
|
||||
htComponentRenamed,
|
||||
htBeforeAddComponent,
|
||||
htComponentAdded,
|
||||
htComponentDeleting,
|
||||
htDeleteComponent,
|
||||
htGetSelectedComponents,
|
||||
htSetSelectedComponents,
|
||||
htBeforeAddPersistent,
|
||||
htPersistentAdded,
|
||||
htPersistentDeleting,
|
||||
htDeletePersistent,
|
||||
htGetSelectedPersistents,
|
||||
htSetSelectedPersistents,
|
||||
// persistent objects
|
||||
htGetObject,
|
||||
htGetObjectName,
|
||||
@ -1148,13 +1148,13 @@ type
|
||||
function GetComponentName(AComponent: TComponent):ShortString;
|
||||
procedure GetComponentNames(TypeData:PTypeData; const Proc:TGetStringProc);
|
||||
function GetRootClassName:ShortString;
|
||||
function BeforeAddComponent(Sender: TObject;
|
||||
AComponentClass: TComponentClass;
|
||||
Parent: TComponent): boolean;
|
||||
function BeforeAddPersistent(Sender: TObject;
|
||||
APersistentClass: TPersistentClass;
|
||||
Parent: TPersistent): boolean;
|
||||
procedure ComponentRenamed(AComponent: TComponent);
|
||||
procedure ComponentAdded(AComponent: TComponent; Select: boolean);
|
||||
procedure ComponentDeleting(AComponent: TComponent);
|
||||
procedure DeleteComponent(var AComponent: TComponent);
|
||||
procedure PersistentAdded(APersistent: TPersistent; Select: boolean);
|
||||
procedure PersistentDeleting(APersistent: TPersistent);
|
||||
procedure DeletePersistent(var APersistent: TPersistent);
|
||||
procedure GetSelection(const ASelection: TPersistentSelectionList);
|
||||
procedure SetSelection(const ASelection: TPersistentSelectionList);
|
||||
procedure SelectOnlyThis(const APersistent: TPersistent);
|
||||
@ -1219,26 +1219,27 @@ type
|
||||
const OnGetRootClassName: TPropHookGetRootClassName);
|
||||
procedure RemoveHandlerGetRootClassName(
|
||||
const OnGetRootClassName: TPropHookGetRootClassName);
|
||||
procedure AddHandlerBeforeAddComponent(
|
||||
const OnBeforeAddComponent: TPropHookBeforeAddComponent);
|
||||
procedure RemoveHandlerBeforeAddComponent(
|
||||
const OnBeforeAddComponent: TPropHookBeforeAddComponent);
|
||||
procedure AddHandlerComponentRenamed(
|
||||
const OnComponentRenamed: TPropHookComponentRenamed);
|
||||
procedure RemoveHandlerComponentRenamed(
|
||||
const OnComponentRenamed: TPropHookComponentRenamed);
|
||||
procedure AddHandlerComponentAdded(
|
||||
const OnComponentAdded: TPropHookComponentAdded);
|
||||
procedure RemoveHandlerComponentAdded(
|
||||
const OnComponentAdded: TPropHookComponentAdded);
|
||||
procedure AddHandlerComponentDeleting(
|
||||
const OnComponentDeleting: TPropHookComponentDeleting);
|
||||
procedure RemoveHandlerComponentDeleting(
|
||||
const OnComponentDeleting: TPropHookComponentDeleting);
|
||||
procedure AddHandlerDeleteComponent(
|
||||
const OnDeleteComponent: TPropHookDeleteComponent);
|
||||
procedure RemoveHandlerDeleteComponent(
|
||||
const OnDeleteComponent: TPropHookDeleteComponent);
|
||||
// persistent selection
|
||||
procedure AddHandlerBeforeAddPersistent(
|
||||
const OnBeforeAddPersistent: TPropHookBeforeAddPersistent);
|
||||
procedure RemoveHandlerBeforeAddPersistent(
|
||||
const OnBeforeAddPersistent: TPropHookBeforeAddPersistent);
|
||||
procedure AddHandlerPersistentAdded(
|
||||
const OnPersistentAdded: TPropHookPersistentAdded);
|
||||
procedure RemoveHandlerPersistentAdded(
|
||||
const OnPersistentAdded: TPropHookPersistentAdded);
|
||||
procedure AddHandlerPersistentDeleting(
|
||||
const OnPersistentDeleting: TPropHookPersistentDeleting);
|
||||
procedure RemoveHandlerPersistentDeleting(
|
||||
const OnPersistentDeleting: TPropHookPersistentDeleting);
|
||||
procedure AddHandlerDeletePersistent(
|
||||
const OnDeletePersistent: TPropHookDeletePersistent);
|
||||
procedure RemoveHandlerDeletePersistent(
|
||||
const OnDeletePersistent: TPropHookDeletePersistent);
|
||||
procedure AddHandlerGetSelection(
|
||||
const OnGetSelection: TPropHookGetSelection);
|
||||
procedure RemoveHandlerGetSelection(
|
||||
@ -3305,15 +3306,20 @@ end;
|
||||
|
||||
Type
|
||||
TCollectionPropertyEditorForm = class(TForm)
|
||||
procedure ListClick(Sender: TObject);
|
||||
procedure AddClick(Sender: TObject);
|
||||
procedure DeleteClick(Sender: TObject);
|
||||
procedure MoveDownButtonClick(Sender: TObject);
|
||||
procedure MoveUpButtonClick(Sender: TObject);
|
||||
protected
|
||||
CollectionList : TListBox;
|
||||
ButtonPanel: TPanel;
|
||||
AddButton: TSpeedButton;
|
||||
DeleteButton: TSpeedButton;
|
||||
procedure ListClick(Sender: TObject);
|
||||
procedure AddClick(Sender: TObject);
|
||||
procedure DeleteClick(Sender: TObject);
|
||||
MoveUpButton: TSpeedButton;
|
||||
MoveDownButton: TSpeedButton;
|
||||
procedure UpdateCaption;
|
||||
procedure UpdateButtons;
|
||||
public
|
||||
Collection: TCollection;
|
||||
PersistentName: string;
|
||||
@ -3326,13 +3332,18 @@ const
|
||||
CollectionForm : TCollectionPropertyEditorForm = nil;
|
||||
|
||||
Constructor TCollectionPropertyEditorForm.Create(TheOwner : TComponent);
|
||||
var
|
||||
x: Integer;
|
||||
y: Integer;
|
||||
w: Integer;
|
||||
h: Integer;
|
||||
begin
|
||||
Inherited Create(TheOwner);
|
||||
|
||||
Position := poDefault;
|
||||
|
||||
Height:= 216;
|
||||
Width:= 166;
|
||||
Width:= 220;
|
||||
|
||||
ButtonPanel := TPanel.Create(Self);
|
||||
With ButtonPanel do begin
|
||||
@ -3344,20 +3355,44 @@ begin
|
||||
Height:= 41;
|
||||
end;
|
||||
|
||||
x:=6;
|
||||
y:=6;
|
||||
w:=43;
|
||||
h:=27;
|
||||
AddButton:= TSpeedButton.Create(Self);
|
||||
With AddButton do begin
|
||||
Parent:= ButtonPanel;
|
||||
Caption:= oiscAdd;
|
||||
OnClick:= @AddClick;
|
||||
SetBounds(6, 6, 43, 27);
|
||||
SetBounds(x,y,w,h);
|
||||
inc(x,w);
|
||||
end;
|
||||
|
||||
DeleteButton := TSpeedButton.Create(Self);
|
||||
With DeleteButton do begin
|
||||
Parent:= ButtonPanel;
|
||||
Caption:= oiscDelete;
|
||||
OnClick:= @DeleteCLICK;
|
||||
SetBounds(56, 6, 43, 27);
|
||||
OnClick:= @DeleteClick;
|
||||
SetBounds(x,y,w,h);
|
||||
inc(x,w);
|
||||
end;
|
||||
|
||||
MoveUpButton := TSpeedButton.Create(Self);
|
||||
With MoveUpButton do begin
|
||||
Parent:= ButtonPanel;
|
||||
Caption:= 'Up'; // replace this by up arrow
|
||||
OnClick:=@MoveUpButtonClick;
|
||||
SetBounds(x,y,w,h);
|
||||
inc(x,w);
|
||||
end;
|
||||
|
||||
MoveDownButton := TSpeedButton.Create(Self);
|
||||
With MoveDownButton do begin
|
||||
Parent:= ButtonPanel;
|
||||
Caption:= 'Down'; // replace this by down arrow
|
||||
OnClick:=@MoveDownButtonClick;
|
||||
SetBounds(x,y,w,h);
|
||||
inc(x,w);
|
||||
end;
|
||||
|
||||
CollectionList := TListBox.Create(Self);
|
||||
@ -3382,6 +3417,16 @@ begin
|
||||
Caption:=NewCaption;
|
||||
end;
|
||||
|
||||
procedure TCollectionPropertyEditorForm.UpdateButtons;
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i:=CollectionList.ItemIndex;
|
||||
DeleteButton.Enabled:= i > -1;
|
||||
MoveUpButton.Enabled:=i>0;
|
||||
MoveDownButton.Enabled:=(i>=0) and (i<Collection.Count-1);
|
||||
end;
|
||||
|
||||
procedure TCollectionPropertyEditorForm.PropagateList;
|
||||
var
|
||||
I : Longint;
|
||||
@ -3402,17 +3447,38 @@ begin
|
||||
end;
|
||||
CollectionList.Items.EndUpdate;
|
||||
|
||||
DeleteButton.Enabled:= CollectionList.ItemIndex > -1;
|
||||
UpdateButtons;
|
||||
UpdateCaption;
|
||||
end;
|
||||
|
||||
procedure TCollectionPropertyEditorForm.MoveDownButtonClick(Sender: TObject);
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i:=CollectionList.ItemIndex;
|
||||
if i>=Collection.Count-1 then exit;
|
||||
Collection.Items[i].Index:=i+1;
|
||||
CollectionList.ItemIndex:=i+1;
|
||||
PropagateList;
|
||||
end;
|
||||
|
||||
procedure TCollectionPropertyEditorForm.MoveUpButtonClick(Sender: TObject);
|
||||
var
|
||||
i: LongInt;
|
||||
begin
|
||||
i:=CollectionList.ItemIndex;
|
||||
if i<=0 then exit;
|
||||
Collection.Items[i].Index:=i-1;
|
||||
CollectionList.ItemIndex:=i-1;
|
||||
PropagateList;
|
||||
end;
|
||||
|
||||
procedure TCollectionPropertyEditorForm.ListClick(Sender: TObject);
|
||||
//var i : integer;
|
||||
var
|
||||
NewSelection: TPersistentSelectionList;
|
||||
i: Integer;
|
||||
begin
|
||||
DeleteButton.Enabled := CollectionList.ItemIndex > -1;
|
||||
UpdateButtons;
|
||||
UpdateCaption;
|
||||
// select in OI
|
||||
NewSelection:=TPersistentSelectionList.Create;
|
||||
@ -3450,7 +3516,7 @@ begin
|
||||
CollectionList.ItemIndex := I;
|
||||
end;
|
||||
end;
|
||||
DeleteButton.Enabled := CollectionList.ItemIndex > -1;
|
||||
UpdateButtons;
|
||||
end;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@ -4961,16 +5027,16 @@ begin
|
||||
Result:=LookupRoot.ClassName;
|
||||
end;
|
||||
|
||||
function TPropertyEditorHook.BeforeAddComponent(Sender: TObject;
|
||||
AComponentClass: TComponentClass; Parent: TComponent): boolean;
|
||||
function TPropertyEditorHook.BeforeAddPersistent(Sender: TObject;
|
||||
APersistentClass: TPersistentClass; Parent: TPersistent): boolean;
|
||||
var
|
||||
i: Integer;
|
||||
Handler: TPropHookBeforeAddComponent;
|
||||
Handler: TPropHookBeforeAddPersistent;
|
||||
begin
|
||||
i:=GetHandlerCount(htBeforeAddComponent);
|
||||
while GetNextHandlerIndex(htBeforeAddComponent,i) do begin
|
||||
Handler:=TPropHookBeforeAddComponent(FHandlers[htBeforeAddComponent][i]);
|
||||
Result:=Handler(Sender,AComponentClass,Parent);
|
||||
i:=GetHandlerCount(htBeforeAddPersistent);
|
||||
while GetNextHandlerIndex(htBeforeAddPersistent,i) do begin
|
||||
Handler:=TPropHookBeforeAddPersistent(FHandlers[htBeforeAddPersistent][i]);
|
||||
Result:=Handler(Sender,APersistentClass,Parent);
|
||||
if not Result then exit;
|
||||
end;
|
||||
Result:=true;
|
||||
@ -4985,36 +5051,36 @@ begin
|
||||
TPropHookComponentRenamed(FHandlers[htComponentRenamed][i])(AComponent);
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.ComponentAdded(AComponent: TComponent;
|
||||
procedure TPropertyEditorHook.PersistentAdded(APersistent: TPersistent;
|
||||
Select: boolean);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:=GetHandlerCount(htComponentAdded);
|
||||
while GetNextHandlerIndex(htComponentAdded,i) do
|
||||
TPropHookComponentAdded(FHandlers[htComponentAdded][i])(AComponent,Select);
|
||||
i:=GetHandlerCount(htPersistentAdded);
|
||||
while GetNextHandlerIndex(htPersistentAdded,i) do
|
||||
TPropHookPersistentAdded(FHandlers[htPersistentAdded][i])(APersistent,Select);
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.ComponentDeleting(AComponent: TComponent);
|
||||
procedure TPropertyEditorHook.PersistentDeleting(APersistent: TPersistent);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
i:=GetHandlerCount(htComponentDeleting);
|
||||
while GetNextHandlerIndex(htComponentDeleting,i) do
|
||||
TPropHookComponentDeleting(FHandlers[htComponentDeleting][i])(AComponent);
|
||||
i:=GetHandlerCount(htPersistentDeleting);
|
||||
while GetNextHandlerIndex(htPersistentDeleting,i) do
|
||||
TPropHookPersistentDeleting(FHandlers[htPersistentDeleting][i])(APersistent);
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.DeleteComponent(var AComponent: TComponent);
|
||||
procedure TPropertyEditorHook.DeletePersistent(var APersistent: TPersistent);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if AComponent=nil then exit;
|
||||
i:=GetHandlerCount(htDeleteComponent);
|
||||
if APersistent=nil then exit;
|
||||
i:=GetHandlerCount(htDeletePersistent);
|
||||
if i>0 then begin
|
||||
while GetNextHandlerIndex(htDeleteComponent,i) do
|
||||
TPropHookDeleteComponent(FHandlers[htDeleteComponent][i])(AComponent);
|
||||
while GetNextHandlerIndex(htDeletePersistent,i) do
|
||||
TPropHookDeletePersistent(FHandlers[htDeletePersistent][i])(APersistent);
|
||||
end else
|
||||
FreeThenNil(AComponent);
|
||||
FreeThenNil(APersistent);
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.GetSelection(
|
||||
@ -5025,9 +5091,9 @@ var
|
||||
begin
|
||||
if ASelection=nil then exit;
|
||||
ASelection.Clear;
|
||||
i:=GetHandlerCount(htGetSelectedComponents);
|
||||
while GetNextHandlerIndex(htGetSelectedComponents,i) do begin
|
||||
Handler:=TPropHookGetSelection(FHandlers[htGetSelectedComponents][i]);
|
||||
i:=GetHandlerCount(htGetSelectedPersistents);
|
||||
while GetNextHandlerIndex(htGetSelectedPersistents,i) do begin
|
||||
Handler:=TPropHookGetSelection(FHandlers[htGetSelectedPersistents][i]);
|
||||
Handler(ASelection);
|
||||
end;
|
||||
end;
|
||||
@ -5061,9 +5127,9 @@ begin
|
||||
// set selection
|
||||
if ASelection=nil then exit;
|
||||
//writeln('TPropertyEditorHook.SetSelection A ASelection.Count=',ASelection.Count);
|
||||
i:=GetHandlerCount(htSetSelectedComponents);
|
||||
while GetNextHandlerIndex(htSetSelectedComponents,i) do begin
|
||||
Handler:=TPropHookSetSelection(FHandlers[htSetSelectedComponents][i]);
|
||||
i:=GetHandlerCount(htSetSelectedPersistents);
|
||||
while GetNextHandlerIndex(htSetSelectedPersistents,i) do begin
|
||||
Handler:=TPropHookSetSelection(FHandlers[htSetSelectedPersistents][i]);
|
||||
Handler(ASelection);
|
||||
end;
|
||||
//writeln('TPropertyEditorHook.SetSelection END ASelection.Count=',ASelection.Count);
|
||||
@ -5317,16 +5383,16 @@ begin
|
||||
RemoveHandler(htGetRootClassName,TMethod(OnGetRootClassName));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerBeforeAddComponent(
|
||||
const OnBeforeAddComponent: TPropHookBeforeAddComponent);
|
||||
procedure TPropertyEditorHook.AddHandlerBeforeAddPersistent(
|
||||
const OnBeforeAddPersistent: TPropHookBeforeAddPersistent);
|
||||
begin
|
||||
AddHandler(htBeforeAddComponent,TMethod(OnBeforeAddComponent));
|
||||
AddHandler(htBeforeAddPersistent,TMethod(OnBeforeAddPersistent));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerBeforeAddComponent(
|
||||
const OnBeforeAddComponent: TPropHookBeforeAddComponent);
|
||||
procedure TPropertyEditorHook.RemoveHandlerBeforeAddPersistent(
|
||||
const OnBeforeAddPersistent: TPropHookBeforeAddPersistent);
|
||||
begin
|
||||
RemoveHandler(htBeforeAddComponent,TMethod(OnBeforeAddComponent));
|
||||
RemoveHandler(htBeforeAddPersistent,TMethod(OnBeforeAddPersistent));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerComponentRenamed(
|
||||
@ -5341,64 +5407,64 @@ begin
|
||||
RemoveHandler(htComponentRenamed,TMethod(OnComponentRenamed));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerComponentAdded(
|
||||
const OnComponentAdded: TPropHookComponentAdded);
|
||||
procedure TPropertyEditorHook.AddHandlerPersistentAdded(
|
||||
const OnPersistentAdded: TPropHookPersistentAdded);
|
||||
begin
|
||||
AddHandler(htComponentAdded,TMethod(OnComponentAdded));
|
||||
AddHandler(htPersistentAdded,TMethod(OnPersistentAdded));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerComponentAdded(
|
||||
const OnComponentAdded: TPropHookComponentAdded);
|
||||
procedure TPropertyEditorHook.RemoveHandlerPersistentAdded(
|
||||
const OnPersistentAdded: TPropHookPersistentAdded);
|
||||
begin
|
||||
RemoveHandler(htComponentAdded,TMethod(OnComponentAdded));
|
||||
RemoveHandler(htPersistentAdded,TMethod(OnPersistentAdded));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerComponentDeleting(
|
||||
const OnComponentDeleting: TPropHookComponentDeleting);
|
||||
procedure TPropertyEditorHook.AddHandlerPersistentDeleting(
|
||||
const OnPersistentDeleting: TPropHookPersistentDeleting);
|
||||
begin
|
||||
AddHandler(htComponentDeleting,TMethod(OnComponentDeleting));
|
||||
AddHandler(htPersistentDeleting,TMethod(OnPersistentDeleting));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerComponentDeleting(
|
||||
const OnComponentDeleting: TPropHookComponentDeleting);
|
||||
procedure TPropertyEditorHook.RemoveHandlerPersistentDeleting(
|
||||
const OnPersistentDeleting: TPropHookPersistentDeleting);
|
||||
begin
|
||||
RemoveHandler(htComponentDeleting,TMethod(OnComponentDeleting));
|
||||
RemoveHandler(htPersistentDeleting,TMethod(OnPersistentDeleting));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerDeleteComponent(
|
||||
const OnDeleteComponent: TPropHookDeleteComponent);
|
||||
procedure TPropertyEditorHook.AddHandlerDeletePersistent(
|
||||
const OnDeletePersistent: TPropHookDeletePersistent);
|
||||
begin
|
||||
AddHandler(htDeleteComponent,TMethod(OnDeleteComponent));
|
||||
AddHandler(htDeletePersistent,TMethod(OnDeletePersistent));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerDeleteComponent(
|
||||
const OnDeleteComponent: TPropHookDeleteComponent);
|
||||
procedure TPropertyEditorHook.RemoveHandlerDeletePersistent(
|
||||
const OnDeletePersistent: TPropHookDeletePersistent);
|
||||
begin
|
||||
RemoveHandler(htDeleteComponent,TMethod(OnDeleteComponent));
|
||||
RemoveHandler(htDeletePersistent,TMethod(OnDeletePersistent));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerGetSelection(
|
||||
const OnGetSelection: TPropHookGetSelection);
|
||||
begin
|
||||
AddHandler(htGetSelectedComponents,TMethod(OnGetSelection));
|
||||
AddHandler(htGetSelectedPersistents,TMethod(OnGetSelection));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerGetSelection(
|
||||
const OnGetSelection: TPropHookGetSelection);
|
||||
begin
|
||||
RemoveHandler(htGetSelectedComponents,TMethod(OnGetSelection));
|
||||
RemoveHandler(htGetSelectedPersistents,TMethod(OnGetSelection));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerSetSelection(
|
||||
const OnSetSelection: TPropHookSetSelection);
|
||||
begin
|
||||
AddHandler(htSetSelectedComponents,TMethod(OnSetSelection));
|
||||
AddHandler(htSetSelectedPersistents,TMethod(OnSetSelection));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.RemoveHandlerSetSelection(
|
||||
const OnSetSelection: TPropHookSetSelection);
|
||||
begin
|
||||
RemoveHandler(htSetSelectedComponents,TMethod(OnSetSelection));
|
||||
RemoveHandler(htSetSelectedPersistents,TMethod(OnSetSelection));
|
||||
end;
|
||||
|
||||
procedure TPropertyEditorHook.AddHandlerGetObject(
|
||||
|
@ -405,15 +405,15 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Assign(ASource: TPersistent); override;
|
||||
published
|
||||
property Alignment: TAlignment read FAlignment write SetAlignment;
|
||||
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
|
||||
property AutoSize: Boolean read FAutoSize write SetAutoSize;
|
||||
property Caption: string read FCaption write SetCaption;
|
||||
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex;
|
||||
property MaxWidth: TWidth read FMaxWidth write SetMaxWidth;
|
||||
property MinWidth: TWidth read FMinWidth write SetMinWidth;
|
||||
property Tag: Integer read FTag write FTag;
|
||||
property Visible : Boolean read FVisible write SetVisible;
|
||||
property Width: TWidth read GetWidth write SetWidth;
|
||||
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
|
||||
property MaxWidth: TWidth read FMaxWidth write SetMaxWidth default 0;
|
||||
property MinWidth: TWidth read FMinWidth write SetMinWidth default 0;
|
||||
property Tag: Integer read FTag write FTag default 0;
|
||||
property Visible : Boolean read FVisible write SetVisible default true;
|
||||
property Width: TWidth read GetWidth write SetWidth default 50;
|
||||
end;
|
||||
|
||||
|
||||
@ -2305,6 +2305,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.140 2004/07/24 11:23:56 mattias
|
||||
Designer can now handle TPersistent selections, TCollectionPropertyEditor basically working
|
||||
|
||||
Revision 1.139 2004/07/24 00:00:33 mattias
|
||||
started TCollectionPropertyEditor
|
||||
|
||||
|
@ -124,6 +124,7 @@ function DbgS(const p: TPoint): string;
|
||||
function DbgS(const p: pointer): string;
|
||||
function DbgS(const e: extended): string;
|
||||
function DbgS(const b: boolean): string;
|
||||
function DbgSName(const p: TPersistent): string;
|
||||
|
||||
function DbgS(const i1,i2,i3,i4: integer): string;
|
||||
|
||||
@ -738,6 +739,16 @@ begin
|
||||
if b then Result:='True' else Result:='False';
|
||||
end;
|
||||
|
||||
function DbgSName(const p: TPersistent): string;
|
||||
begin
|
||||
if p=nil then
|
||||
Result:='nil'
|
||||
else if p is TComponent then
|
||||
Result:=TComponent(p).Name+':'+p.ClassName
|
||||
else
|
||||
Result:=p.ClassName;
|
||||
end;
|
||||
|
||||
function DbgS(const i1, i2, i3, i4: integer): string;
|
||||
begin
|
||||
Result:=dbgs(i1)+','+dbgs(i2)+','+dbgs(i3)+','+dbgs(i4);
|
||||
|
Loading…
Reference in New Issue
Block a user