mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 04:19:12 +02:00
IDEIntf: Tweak Object Inspector such that TFlowPanelControl items cannot be added and deleted in an incorrect way (issue #34286).
git-svn-id: trunk@59133 -
This commit is contained in:
parent
495496eec3
commit
94c1307bb0
@ -784,6 +784,7 @@ type
|
|||||||
procedure SetShowRestricted(const AValue: Boolean);
|
procedure SetShowRestricted(const AValue: Boolean);
|
||||||
procedure SetShowStatusBar(const AValue: Boolean);
|
procedure SetShowStatusBar(const AValue: Boolean);
|
||||||
protected
|
protected
|
||||||
|
function CanDeleteSelection: Boolean;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
procedure Resize; override;
|
procedure Resize; override;
|
||||||
@ -4949,11 +4950,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TObjectInspectorDlg.CanDeleteSelection: Boolean;
|
||||||
|
var
|
||||||
|
persistent: TPersistent;
|
||||||
|
intf: IObjInspInterface;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
Result := true;
|
||||||
|
for i:=0 to ComponentTree.Selection.Count - 1 do begin
|
||||||
|
persistent := ComponentTree.Selection[i];
|
||||||
|
if persistent.GetInterface(GUID_ObjInspInterface, intf) and not intf.AllowDelete then
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TObjectInspectorDlg.ComponentTreeKeyDown(Sender: TObject;
|
procedure TObjectInspectorDlg.ComponentTreeKeyDown(Sender: TObject;
|
||||||
var Key: Word; Shift: TShiftState);
|
var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if (Shift = []) and (Key = VK_DELETE) and
|
if (Shift = []) and (Key = VK_DELETE) and
|
||||||
(Selection.Count > 0) and
|
(Selection.Count > 0) and CanDeleteSelection and
|
||||||
(MessageDlg(oiscDelete, mtConfirmation,[mbYes, mbNo],0) = mrYes) then
|
(MessageDlg(oiscDelete, mtConfirmation,[mbYes, mbNo],0) = mrYes) then
|
||||||
begin
|
begin
|
||||||
DeletePopupmenuItemClick(nil);
|
DeletePopupmenuItemClick(nil);
|
||||||
@ -5707,7 +5725,11 @@ var
|
|||||||
procedure AddCollectionEditorMenuItems({%H-}ACollection: TCollection);
|
procedure AddCollectionEditorMenuItems({%H-}ACollection: TCollection);
|
||||||
var
|
var
|
||||||
Item: TMenuItem;
|
Item: TMenuItem;
|
||||||
|
intf: IObjInspInterface;
|
||||||
begin
|
begin
|
||||||
|
if ACollection.GetInterface(GUID_ObjInspInterface, intf) and not intf.AllowAdd then
|
||||||
|
exit;
|
||||||
|
|
||||||
Item := NewItem(oisAddCollectionItem, 0, False, True,
|
Item := NewItem(oisAddCollectionItem, 0, False, True,
|
||||||
@CollectionAddItem, 0, ComponentEditorMIPrefix+'0');
|
@CollectionAddItem, 0, ComponentEditorMIPrefix+'0');
|
||||||
MainPopupMenu.Items.Insert(0, Item);
|
MainPopupMenu.Items.Insert(0, Item);
|
||||||
|
@ -34,6 +34,8 @@ interface
|
|||||||
// {$DEFINE ASSERT_IS_ON}
|
// {$DEFINE ASSERT_IS_ON}
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
{$INTERFACES CORBA}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, TypInfo, Types, Laz_AVL_Tree,
|
Classes, SysUtils, TypInfo, Types, Laz_AVL_Tree,
|
||||||
// LCL
|
// LCL
|
||||||
@ -79,7 +81,15 @@ const
|
|||||||
// Mac and iOS use Meta instead of Ctrl for those shortcuts
|
// Mac and iOS use Meta instead of Ctrl for those shortcuts
|
||||||
ssModifier = {$if defined(darwin) or defined(macos) or defined(iphonesim)} ssMeta {$else} ssCtrl {$endif};
|
ssModifier = {$if defined(darwin) or defined(macos) or defined(iphonesim)} ssMeta {$else} ssCtrl {$endif};
|
||||||
|
|
||||||
|
GUID_ObjInspInterface = '{37417989-8C8F-4A2D-9D26-0FA377E8D8CC}';
|
||||||
|
|
||||||
type
|
type
|
||||||
|
IObjInspInterface = interface
|
||||||
|
[GUID_ObjInspInterface]
|
||||||
|
function AllowAdd: Boolean;
|
||||||
|
function AllowDelete: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
TWinControl = class;
|
TWinControl = class;
|
||||||
TControl = class;
|
TControl = class;
|
||||||
TWinControlClass = class of TWinControl;
|
TWinControlClass = class of TWinControl;
|
||||||
|
@ -1168,7 +1168,7 @@ type
|
|||||||
waAvoid, // try not to wrap after this control, if the control is already at the beginning of the row, wrap though
|
waAvoid, // try not to wrap after this control, if the control is already at the beginning of the row, wrap though
|
||||||
waForbid); // never wrap after this control
|
waForbid); // never wrap after this control
|
||||||
|
|
||||||
TFlowPanelControl = class(TCollectionItem)
|
TFlowPanelControl = class(TCollectionItem, IObjInspInterface)
|
||||||
private
|
private
|
||||||
FControl: TControl;
|
FControl: TControl;
|
||||||
FWrapAfter: TWrapAfter;
|
FWrapAfter: TWrapAfter;
|
||||||
@ -1180,13 +1180,17 @@ type
|
|||||||
procedure AssignTo(Dest: TPersistent); override;
|
procedure AssignTo(Dest: TPersistent); override;
|
||||||
function FPCollection: TFlowPanelControlList;
|
function FPCollection: TFlowPanelControlList;
|
||||||
function FPOwner: TCustomFlowPanel;
|
function FPOwner: TCustomFlowPanel;
|
||||||
|
public
|
||||||
|
// These methods are used by the Object Inspector only
|
||||||
|
function AllowAdd: Boolean;
|
||||||
|
function AllowDelete: Boolean;
|
||||||
published
|
published
|
||||||
property Control: TControl read FControl write SetControl;
|
property Control: TControl read FControl write SetControl;
|
||||||
property WrapAfter: TWrapAfter read FWrapAfter write SetWrapAfter;
|
property WrapAfter: TWrapAfter read FWrapAfter write SetWrapAfter;
|
||||||
property Index;
|
property Index;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TFlowPanelControlList = class(TOwnedCollection)
|
TFlowPanelControlList = class(TOwnedCollection, IObjInspInterface)
|
||||||
private
|
private
|
||||||
function GetItem(Index: Integer): TFlowPanelControl;
|
function GetItem(Index: Integer): TFlowPanelControl;
|
||||||
procedure SetItem(Index: Integer; const AItem: TFlowPanelControl);
|
procedure SetItem(Index: Integer; const AItem: TFlowPanelControl);
|
||||||
@ -1200,8 +1204,11 @@ type
|
|||||||
constructor Create(AOwner: TPersistent);
|
constructor Create(AOwner: TPersistent);
|
||||||
public
|
public
|
||||||
function IndexOf(AControl: TControl): Integer;
|
function IndexOf(AControl: TControl): Integer;
|
||||||
|
|
||||||
property Items[Index: Integer]: TFlowPanelControl read GetItem write SetItem; default;
|
property Items[Index: Integer]: TFlowPanelControl read GetItem write SetItem; default;
|
||||||
|
public
|
||||||
|
// These methods are used by the Object Inspector only
|
||||||
|
function AllowAdd: Boolean;
|
||||||
|
function AllowDelete: Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCustomFlowPanel = class(TCustomPanel)
|
TCustomFlowPanel = class(TCustomPanel)
|
||||||
|
@ -56,6 +56,16 @@ begin
|
|||||||
Item.FControl := AControl;
|
Item.FControl := AControl;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFlowPanelControlList.AllowAdd: Boolean;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFlowPanelControlList.AllowDelete: Boolean;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFlowPanelControlList.FPOwner: TCustomFlowPanel;
|
function TFlowPanelControlList.FPOwner: TCustomFlowPanel;
|
||||||
begin
|
begin
|
||||||
Result := TCustomFlowPanel(GetOwner);
|
Result := TCustomFlowPanel(GetOwner);
|
||||||
@ -108,6 +118,16 @@ begin
|
|||||||
inherited AssignTo(Dest);
|
inherited AssignTo(Dest);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFlowPanelControl.AllowAdd: Boolean;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TFlowPanelControl.AllowDelete: Boolean;
|
||||||
|
begin
|
||||||
|
Result := false;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFlowPanelControl.FPCollection: TFlowPanelControlList;
|
function TFlowPanelControl.FPCollection: TFlowPanelControlList;
|
||||||
begin
|
begin
|
||||||
Result := Collection as TFlowPanelControlList;
|
Result := Collection as TFlowPanelControlList;
|
||||||
@ -131,6 +151,8 @@ begin
|
|||||||
if FControl = aControl then Exit;
|
if FControl = aControl then Exit;
|
||||||
Assert(FControl = nil);
|
Assert(FControl = nil);
|
||||||
FControl := aControl;
|
FControl := aControl;
|
||||||
|
if FControl <> nil then
|
||||||
|
FControl.Parent := FPOwner;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFlowPanelControl.SetIndex(Value: Integer);
|
procedure TFlowPanelControl.SetIndex(Value: Integer);
|
||||||
@ -178,6 +200,8 @@ var
|
|||||||
for I := BStartControl to BEndControl do
|
for I := BStartControl to BEndControl do
|
||||||
begin
|
begin
|
||||||
xControl := FControlList[I].Control;
|
xControl := FControlList[I].Control;
|
||||||
|
if xControl = nil then
|
||||||
|
Continue;
|
||||||
if not xControl.Visible and not (csDesigning in ComponentState) then
|
if not xControl.Visible and not (csDesigning in ComponentState) then
|
||||||
Continue;
|
Continue;
|
||||||
|
|
||||||
@ -239,6 +263,8 @@ begin
|
|||||||
for I := 0 to FControlList.Count-1 do
|
for I := 0 to FControlList.Count-1 do
|
||||||
begin
|
begin
|
||||||
xControl := FControlList[I].Control;
|
xControl := FControlList[I].Control;
|
||||||
|
if xControl = nil then
|
||||||
|
Continue;
|
||||||
xConBS := xControl.BorderSpacing;
|
xConBS := xControl.BorderSpacing;
|
||||||
if not xControl.Visible and not (csDesigning in ComponentState) then
|
if not xControl.Visible and not (csDesigning in ComponentState) then
|
||||||
continue;
|
continue;
|
||||||
@ -341,6 +367,8 @@ begin
|
|||||||
for I := 0 to FControlList.Count-1 do
|
for I := 0 to FControlList.Count-1 do
|
||||||
begin
|
begin
|
||||||
xControl := FControlList[I].Control;
|
xControl := FControlList[I].Control;
|
||||||
|
if xControl = nil then
|
||||||
|
continue;
|
||||||
xConBS := xControl.BorderSpacing;
|
xConBS := xControl.BorderSpacing;
|
||||||
if not xControl.Visible and not (csDesigning in ComponentState) then
|
if not xControl.Visible and not (csDesigning in ComponentState) then
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user