mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-24 01:59:43 +02:00
IDE: component list: add "keep open" option for Delphi behavior. Issue #30459
git-svn-id: trunk@53260 -
This commit is contained in:
parent
f7daccaf3b
commit
6e6f2e7c16
@ -12,11 +12,10 @@ object ComponentListForm: TComponentListForm
|
||||
OnKeyDown = FormKeyDown
|
||||
OnShow = FormShow
|
||||
LCLVersion = '1.7'
|
||||
Visible = False
|
||||
object PageControl: TPageControl
|
||||
Left = 0
|
||||
Height = 394
|
||||
Top = 31
|
||||
Height = 397
|
||||
Top = 27
|
||||
Width = 300
|
||||
ActivePage = TabSheetList
|
||||
Align = alClient
|
||||
@ -25,24 +24,24 @@ object ComponentListForm: TComponentListForm
|
||||
OnChange = PageControlChange
|
||||
object TabSheetList: TTabSheet
|
||||
Caption = 'List'
|
||||
ClientHeight = 361
|
||||
ClientWidth = 296
|
||||
ClientHeight = 369
|
||||
ClientWidth = 292
|
||||
object Panel7: TPanel
|
||||
Left = 0
|
||||
Height = 361
|
||||
Height = 369
|
||||
Top = 0
|
||||
Width = 296
|
||||
Width = 292
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
BorderWidth = 2
|
||||
ClientHeight = 361
|
||||
ClientWidth = 296
|
||||
ClientHeight = 369
|
||||
ClientWidth = 292
|
||||
TabOrder = 0
|
||||
object ListTree: TTreeView
|
||||
Left = 2
|
||||
Height = 357
|
||||
Height = 365
|
||||
Top = 2
|
||||
Width = 292
|
||||
Width = 288
|
||||
Align = alClient
|
||||
DefaultItemHeight = 26
|
||||
Images = imListPalette
|
||||
@ -138,22 +137,22 @@ object ComponentListForm: TComponentListForm
|
||||
end
|
||||
object FilterPanel: TPanel
|
||||
Left = 0
|
||||
Height = 31
|
||||
Height = 27
|
||||
Top = 0
|
||||
Width = 300
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 31
|
||||
ClientHeight = 27
|
||||
ClientWidth = 300
|
||||
TabOrder = 0
|
||||
object LabelSearch: TLabel
|
||||
AnchorSideLeft.Control = FilterPanel
|
||||
AnchorSideTop.Control = FilterPanel
|
||||
Left = 6
|
||||
Height = 19
|
||||
Height = 15
|
||||
Top = 6
|
||||
Width = 86
|
||||
Width = 63
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'LabelSearch'
|
||||
ParentColor = False
|
||||
@ -163,10 +162,10 @@ object ComponentListForm: TComponentListForm
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = LabelSearch
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 98
|
||||
Height = 29
|
||||
Top = 1
|
||||
Width = 198
|
||||
Left = 75
|
||||
Height = 23
|
||||
Top = 2
|
||||
Width = 221
|
||||
OnAfterFilter = TreeFilterEdAfterFilter
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
@ -177,23 +176,37 @@ object ComponentListForm: TComponentListForm
|
||||
FilteredTreeview = ListTree
|
||||
end
|
||||
end
|
||||
object ButtonPanel: TButtonPanel
|
||||
Left = 6
|
||||
Height = 30
|
||||
Top = 431
|
||||
Width = 288
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
OKButton.OnClick = OKButtonClick
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
object ButtonPanel: TPanel
|
||||
Left = 0
|
||||
Height = 43
|
||||
Top = 424
|
||||
Width = 300
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 43
|
||||
ClientWidth = 300
|
||||
TabOrder = 2
|
||||
ShowButtons = [pbOK]
|
||||
ShowBevel = False
|
||||
object chbKeepOpen: TCheckBox
|
||||
Left = 8
|
||||
Height = 19
|
||||
Top = 10
|
||||
Width = 95
|
||||
Caption = 'chbKeepOpen'
|
||||
OnChange = chbKeepOpenChange
|
||||
TabOrder = 0
|
||||
end
|
||||
object OKButton: TButton
|
||||
Left = 208
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 85
|
||||
Anchors = [akTop, akRight]
|
||||
Caption = 'OKButton'
|
||||
Default = True
|
||||
ModalResult = 1
|
||||
OnClick = OKButtonClick
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object imListPalette: TImageList
|
||||
Height = 24
|
||||
|
@ -33,23 +33,25 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLType, Forms, Controls, Graphics, StdCtrls, ExtCtrls,
|
||||
ComCtrls, ButtonPanel, Menus, LazarusIDEStrConsts, ComponentReg, PackageDefs,
|
||||
IDEImagesIntf, TreeFilterEdit, FormEditingIntf, IDEOptionDefs;
|
||||
ComCtrls, Menus, Dialogs, LazarusIDEStrConsts, ComponentReg, PackageDefs,
|
||||
IDEImagesIntf, TreeFilterEdit, FormEditingIntf, PropEdits, IDEOptionDefs,
|
||||
EnvironmentOpts, Designer;
|
||||
|
||||
type
|
||||
|
||||
{ TComponentListForm }
|
||||
|
||||
TComponentListForm = class(TForm)
|
||||
chbKeepOpen: TCheckBox;
|
||||
imListPalette: TImageList;
|
||||
imInheritance: TImageList;
|
||||
ListTree: TTreeView;
|
||||
ButtonPanel: TButtonPanel;
|
||||
ButtonPanel: TPanel;
|
||||
miCollapse: TMenuItem;
|
||||
miCollapseAll: TMenuItem;
|
||||
miExpand: TMenuItem;
|
||||
miExpandAll: TMenuItem;
|
||||
OKButton: TPanelBitBtn;
|
||||
OKButton: TButton;
|
||||
LabelSearch: TLabel;
|
||||
PageControl: TPageControl;
|
||||
FilterPanel: TPanel;
|
||||
@ -64,6 +66,7 @@ type
|
||||
TabSheetList: TTabSheet;
|
||||
tmDeselect: TTimer;
|
||||
TreeFilterEd: TTreeFilterEdit;
|
||||
procedure chbKeepOpenChange(Sender: TObject);
|
||||
procedure FormActivate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure ListTreeSelectionChanged(Sender: TObject);
|
||||
@ -90,6 +93,8 @@ type
|
||||
FIgnoreSelection: Boolean;
|
||||
FPageControlChange: Boolean;
|
||||
FActiveTree: TTreeView;
|
||||
FAddCompNewLeft, FAddCompNewTop: Integer;
|
||||
FAddCompNewParent: TComponent;
|
||||
procedure ClearSelection;
|
||||
procedure SelectionWasChanged;
|
||||
procedure ComponentWasAdded({%H-}ALookupRoot, {%H-}AComponent: TComponent;
|
||||
@ -97,6 +102,8 @@ type
|
||||
procedure DoComponentInheritence(Comp: TRegisteredComponent);
|
||||
procedure UpdateComponents;
|
||||
procedure UpdateButtonState;
|
||||
function IsDocked: Boolean;
|
||||
procedure AddSelectedComponent;
|
||||
protected
|
||||
procedure UpdateShowing; override;
|
||||
public
|
||||
@ -126,7 +133,8 @@ begin
|
||||
TabSheetList.Caption := lisCmpLstList;
|
||||
TabSheetPaletteTree.Caption := lisCmpLstPalette;
|
||||
TabSheetInheritance.Caption := lisCmpLstInheritance;
|
||||
ButtonPanel.OKButton.Caption := lisUseAndClose;
|
||||
OKButton.Caption := lisUse;
|
||||
chbKeepOpen.Caption := lisKeepOpen;
|
||||
|
||||
imListPalette.Width := ComponentPaletteImageWidth;
|
||||
imListPalette.Height := ComponentPaletteImageHeight;
|
||||
@ -145,6 +153,56 @@ begin
|
||||
IDEComponentPalette.AddHandlerSelectionChanged(@SelectionWasChanged);
|
||||
IDEComponentPalette.AddHandlerComponentAdded(@ComponentWasAdded);
|
||||
end;
|
||||
|
||||
chbKeepOpen.Checked := EnvironmentOptions.ComponentListKeepOpen;
|
||||
end;
|
||||
|
||||
procedure TComponentListForm.AddSelectedComponent;
|
||||
var
|
||||
AComponent: TRegisteredComponent;
|
||||
ASelections: TPersistentSelectionList;
|
||||
NewParent: TComponent;
|
||||
CurDesigner: TDesigner;
|
||||
begin
|
||||
AComponent := GetSelectedComponent;
|
||||
ASelections := TPersistentSelectionList.Create;
|
||||
try
|
||||
GlobalDesignHook.GetSelection(ASelections);
|
||||
if (ASelections.Count>0) and (ASelections[0] is TComponent) then
|
||||
NewParent := TComponent(ASelections[0])
|
||||
else if GlobalDesignHook.LookupRoot is TComponent then
|
||||
NewParent := TComponent(GlobalDesignHook.LookupRoot)
|
||||
else
|
||||
NewParent := nil;
|
||||
finally
|
||||
ASelections.Free;
|
||||
end;
|
||||
|
||||
if NewParent=nil then
|
||||
Exit;
|
||||
|
||||
CurDesigner:=TDesigner(FindRootDesigner(NewParent));
|
||||
if CurDesigner=nil then
|
||||
Exit;
|
||||
|
||||
CurDesigner.AddComponentCheckParent(NewParent, NewParent, nil, AComponent.ComponentClass);
|
||||
if NewParent=nil then
|
||||
Exit;
|
||||
|
||||
if FAddCompNewParent<>NewParent then
|
||||
begin
|
||||
FAddCompNewLeft := 0;
|
||||
FAddCompNewTop := 0;
|
||||
FAddCompNewParent := NewParent;
|
||||
end;
|
||||
Inc(FAddCompNewLeft, 8);
|
||||
Inc(FAddCompNewTop, 8);
|
||||
CurDesigner.AddComponent(AComponent, AComponent.ComponentClass, NewParent, FAddCompNewLeft, FAddCompNewTop, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TComponentListForm.chbKeepOpenChange(Sender: TObject);
|
||||
begin
|
||||
EnvironmentOptions.ComponentListKeepOpen := chbKeepOpen.Checked;
|
||||
end;
|
||||
|
||||
destructor TComponentListForm.Destroy;
|
||||
@ -158,7 +216,7 @@ end;
|
||||
procedure TComponentListForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
//DebugLn(['*** TComponentListForm.FormShow, Parent=', Parent, ', Parent.Parent=', ParentParent]);
|
||||
ButtonPanel.Visible := (HostDockSite=Nil) or (HostDockSite.Parent=Nil);
|
||||
ButtonPanel.Visible := not IsDocked;
|
||||
if ButtonPanel.Visible then
|
||||
begin // ComponentList is undocked
|
||||
PageControl.AnchorSideBottom.Side := asrTop;
|
||||
@ -231,6 +289,11 @@ begin
|
||||
Result := GetSelectedTreeComp(InheritanceTree)
|
||||
end;
|
||||
|
||||
function TComponentListForm.IsDocked: Boolean;
|
||||
begin
|
||||
Result := (HostDockSite<>Nil) and (HostDockSite.Parent<>Nil);
|
||||
end;
|
||||
|
||||
procedure TComponentListForm.ComponentWasAdded(ALookupRoot, AComponent: TComponent;
|
||||
ARegisteredComponent: TRegisteredComponent);
|
||||
begin
|
||||
@ -240,7 +303,7 @@ end;
|
||||
|
||||
procedure TComponentListForm.UpdateButtonState;
|
||||
begin
|
||||
ButtonPanel.OKButton.Enabled := Assigned(GetSelectedComponent);
|
||||
OKButton.Enabled := Assigned(GetSelectedComponent);
|
||||
end;
|
||||
|
||||
procedure TComponentListForm.UpdateShowing;
|
||||
@ -459,23 +522,10 @@ end;
|
||||
|
||||
procedure TComponentListForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
if Parent=nil then begin
|
||||
if not FKeepSelected then
|
||||
begin
|
||||
ClearSelection;
|
||||
if not fKeepSelected then
|
||||
IDEComponentPalette.Selected := Nil;
|
||||
end
|
||||
else begin
|
||||
// Using a dock manager...
|
||||
CloseAction := caNone;
|
||||
//todo: helper function in DockManager or IDEDockMaster for closing forms.
|
||||
// Only close the window if it's floating.
|
||||
// AnchorDocking doesn't seem to initialize 'FloatingDockSiteClass' so we can't just check 'Floating'.
|
||||
// Also, AnchorDocking use nested forms, so the check for HostDockSite.Parent.
|
||||
if Assigned(HostDockSite) and (HostDockSite.DockClientCount <= 1)
|
||||
and (HostDockSite is TCustomForm) and (HostDockSite.Parent = nil) then
|
||||
begin
|
||||
TCustomForm(HostDockSite).Close;
|
||||
end;
|
||||
IDEComponentPalette.Selected := Nil;
|
||||
end;
|
||||
FKeepSelected := False;
|
||||
end;
|
||||
@ -484,7 +534,7 @@ procedure TComponentListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift:
|
||||
begin
|
||||
if Key=VK_ESCAPE then
|
||||
begin
|
||||
if IDEComponentPalette.Selected = nil then //close only if no component is selected
|
||||
if (IDEComponentPalette.Selected = nil) and not IsDocked then //close only if no component is selected
|
||||
Close
|
||||
else
|
||||
ClearSelection; //unselect if component is selected
|
||||
@ -497,13 +547,15 @@ var
|
||||
AComponent: TRegisteredComponent;
|
||||
begin
|
||||
AComponent := GetSelectedComponent;
|
||||
if AComponent<>nil then begin
|
||||
FPageControlChange:=True;
|
||||
IDEComponentPalette.Selected := AComponent;
|
||||
if AComponent=nil then
|
||||
Exit;
|
||||
|
||||
if IsDocked or chbKeepOpen.Checked then
|
||||
AddSelectedComponent
|
||||
else
|
||||
begin
|
||||
FKeepSelected := True;
|
||||
Close;
|
||||
if Assigned(IDEComponentPalette.OnClassSelected) then
|
||||
IDEComponentPalette.OnClassSelected(Self);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -552,6 +552,9 @@ type
|
||||
FNewUnitTemplate: string;
|
||||
FFileDialogFilter: string;
|
||||
|
||||
//component list
|
||||
FComponentListKeepOpen: Boolean;
|
||||
|
||||
// Desktop
|
||||
FDesktops: TDesktopOptList;
|
||||
FDesktop: TDesktopOpt;
|
||||
@ -850,6 +853,9 @@ type
|
||||
property MsgColors[u: TMessageLineUrgency]: TColor read GetMsgColors write SetMsgColors;
|
||||
property MsgViewShowFPCMsgLinesCompiled: Boolean read FMsgViewShowFPCMsgLinesCompiled write FMsgViewShowFPCMsgLinesCompiled;
|
||||
|
||||
//component list
|
||||
property ComponentListKeepOpen: Boolean read FComponentListKeepOpen write FComponentListKeepOpen;
|
||||
|
||||
// glyphs
|
||||
property ShowButtonGlyphs: TApplicationShowGlyphs read FShowButtonGlyphs write FShowButtonGlyphs;
|
||||
property ShowMenuGlyphs: TApplicationShowGlyphs read FShowMenuGlyphs write FShowMenuGlyphs;
|
||||
@ -1828,6 +1834,9 @@ begin
|
||||
MsgViewFilters.LoadFromXMLConfig(FXMLCfg,'MsgView/Filters/');
|
||||
FMsgViewShowFPCMsgLinesCompiled:=FXMLCfg.GetValue(Path+'MsgView/FPCMsg/ShowLinesCompiled',false);
|
||||
|
||||
//component list
|
||||
FComponentListKeepOpen:=FXMLCfg.GetValue(Path+'ComponentList/KeepOpen',false);
|
||||
|
||||
// glyphs
|
||||
FShowButtonGlyphs := TApplicationShowGlyphs(FXMLCfg.GetValue(Path+'ShowButtonGlyphs/Value',
|
||||
Ord(sbgSystem)));
|
||||
@ -2175,6 +2184,9 @@ begin
|
||||
MsgViewFilters.SaveToXMLConfig(FXMLCfg,'MsgView/Filters/');
|
||||
FXMLCfg.SetDeleteValue(Path+'MsgView/FPCMsg/ShowLinesCompiled',FMsgViewShowFPCMsgLinesCompiled,false);
|
||||
|
||||
//component list
|
||||
FXMLCfg.SetDeleteValue(Path+'ComponentList/KeepOpen',FComponentListKeepOpen,false);
|
||||
|
||||
// glyphs
|
||||
FXMLCfg.SetDeleteValue(Path+'ShowButtonGlyphs/Value',Ord(FShowButtonGlyphs), Ord(sbgSystem));
|
||||
FXMLCfg.SetDeleteValue(Path+'ShowMenuGlyphs/Value',Ord(FShowMenuGlyphs), Ord(sbgSystem));
|
||||
|
@ -211,6 +211,7 @@ resourcestring
|
||||
lisSelectionTool = 'Selection tool';
|
||||
lisClickToSelectPalettePage = 'Click to Select Palette Page';
|
||||
lisTotalPages = 'Total Pages: %s';
|
||||
lisKeepOpen = 'keep open';
|
||||
|
||||
// macros
|
||||
lisCursorColumnInCurrentEditor = 'Cursor column in current editor';
|
||||
@ -345,7 +346,6 @@ resourcestring
|
||||
lisKMSelectLineEnd = 'Select Line End';
|
||||
lisKMSelectPageTop = 'Select Page Top';
|
||||
lisKMSelectPageBottom = 'Select Page Bottom';
|
||||
lisUseAndClose = 'Use and close';
|
||||
lisMenuSelect = 'Select';
|
||||
lisMenuMultiPaste = 'MultiPaste ...';
|
||||
lisMenuSelectAll = 'Select All';
|
||||
|
Loading…
Reference in New Issue
Block a user