mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-23 12:26:08 +02:00
IDE: Improve Component List's behavior. Issue #22829
git-svn-id: trunk@38604 -
This commit is contained in:
parent
bc63059885
commit
ecdb186fb6
@ -51,6 +51,7 @@ object ComponentListForm: TComponentListForm
|
|||||||
Width = 328
|
Width = 328
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
|
OnClick = ComponentsClick
|
||||||
OnDblClick = ComponentsDblClick
|
OnDblClick = ComponentsDblClick
|
||||||
OnDrawItem = ComponentsListboxDrawItem
|
OnDrawItem = ComponentsListboxDrawItem
|
||||||
OnKeyDown = ComponentsListboxKeyDown
|
OnKeyDown = ComponentsListboxKeyDown
|
||||||
@ -187,14 +188,15 @@ object ComponentListForm: TComponentListForm
|
|||||||
Width = 326
|
Width = 326
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.DefaultCaption = True
|
OKButton.DefaultCaption = True
|
||||||
|
OKButton.OnClick = OKButtonClick
|
||||||
HelpButton.Name = 'HelpButton'
|
HelpButton.Name = 'HelpButton'
|
||||||
HelpButton.DefaultCaption = True
|
HelpButton.DefaultCaption = True
|
||||||
CloseButton.Name = 'CloseButton'
|
CloseButton.Name = 'CloseButton'
|
||||||
CloseButton.DefaultCaption = True
|
CloseButton.DefaultCaption = True
|
||||||
CloseButton.OnClick = CloseButtonClick
|
|
||||||
CancelButton.Name = 'CancelButton'
|
CancelButton.Name = 'CancelButton'
|
||||||
CancelButton.DefaultCaption = True
|
CancelButton.DefaultCaption = True
|
||||||
|
CancelButton.OnClick = CancelButtonClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
ShowButtons = [pbOK, pbClose]
|
ShowButtons = [pbOK, pbCancel]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -58,9 +58,10 @@ type
|
|||||||
InheritanceTree: TTreeView;
|
InheritanceTree: TTreeView;
|
||||||
PalletteTree: TTreeView;
|
PalletteTree: TTreeView;
|
||||||
TreeFilterEd: TTreeFilterEdit;
|
TreeFilterEd: TTreeFilterEdit;
|
||||||
procedure ButtonPanelOKButtonClick(Sender: TObject);
|
procedure CancelButtonClick(Sender: TObject);
|
||||||
procedure CloseButtonClick(Sender: TObject);
|
procedure OKButtonClick(Sender: TObject);
|
||||||
procedure ComponentsDblClick(Sender: TObject);
|
procedure ComponentsDblClick(Sender: TObject);
|
||||||
|
procedure ComponentsClick(Sender: TObject);
|
||||||
procedure ComponentsListboxDrawItem(Control: TWinControl; Index: Integer;
|
procedure ComponentsListboxDrawItem(Control: TWinControl; Index: Integer;
|
||||||
ARect: TRect; State: TOwnerDrawState);
|
ARect: TRect; State: TOwnerDrawState);
|
||||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
@ -76,7 +77,6 @@ type
|
|||||||
PrevPageIndex: Integer;
|
PrevPageIndex: Integer;
|
||||||
FComponentList: TRegisteredCompList;
|
FComponentList: TRegisteredCompList;
|
||||||
procedure FindAllLazarusComponents;
|
procedure FindAllLazarusComponents;
|
||||||
procedure AddSelectedComponent(AComponent: TRegisteredComponent);
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -96,12 +96,10 @@ constructor TComponentListForm.Create(AOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FComponentList := TRegisteredCompList.Create;
|
FComponentList := TRegisteredCompList.Create;
|
||||||
ButtonPanel.CloseButton.Cancel := True;
|
ButtonPanel.OKButton.Caption := lisUseSelected;
|
||||||
ButtonPanel.OKButton.OnClick:=@ButtonPanelOKButtonClick;
|
ComponentsListBox.ItemHeight := ComponentPaletteImageHeight + 1;
|
||||||
ButtonPanel.OKButton.Caption:=lisMenuSelect;
|
InheritanceTree.DefaultItemHeight:= ComponentPaletteImageHeight + 1;
|
||||||
ComponentsListBox.ItemHeight :=ComponentPaletteImageHeight + 1;
|
PalletteTree.DefaultItemHeight := ComponentPaletteImageHeight + 1;
|
||||||
InheritanceTree.DefaultItemHeight:=ComponentPaletteImageHeight + 1;
|
|
||||||
PalletteTree.DefaultItemHeight :=ComponentPaletteImageHeight + 1;
|
|
||||||
|
|
||||||
//Translations..
|
//Translations..
|
||||||
LabelSearch.Caption := lisMenuFind;
|
LabelSearch.Caption := lisMenuFind;
|
||||||
@ -111,8 +109,8 @@ begin
|
|||||||
TabSheetInheritance.Caption := lisCmpLstInheritance;
|
TabSheetInheritance.Caption := lisCmpLstInheritance;
|
||||||
|
|
||||||
//PLEASE add a defaultpage property in TPagecontrol
|
//PLEASE add a defaultpage property in TPagecontrol
|
||||||
PageControl.ActivePage := TabSheetListBox;
|
|
||||||
PrevPageIndex := -1;
|
PrevPageIndex := -1;
|
||||||
|
PageControl.ActivePage := TabSheetListBox;
|
||||||
TreeFilterEd.Visible := False;
|
TreeFilterEd.Visible := False;
|
||||||
|
|
||||||
FindAllLazarusComponents;
|
FindAllLazarusComponents;
|
||||||
@ -137,11 +135,13 @@ begin
|
|||||||
i:=ComponentsListbox.ItemIndex;
|
i:=ComponentsListbox.ItemIndex;
|
||||||
if i>=0 then
|
if i>=0 then
|
||||||
Result:=TRegisteredComponent(ComponentsListbox.Items.Objects[i]);
|
Result:=TRegisteredComponent(ComponentsListbox.Items.Objects[i]);
|
||||||
end else if PalletteTree.IsVisible then
|
end
|
||||||
|
else if PalletteTree.IsVisible then
|
||||||
begin
|
begin
|
||||||
if Assigned(PalletteTree.Selected) then
|
if Assigned(PalletteTree.Selected) then
|
||||||
Result := TRegisteredComponent(PalletteTree.Selected.Data);
|
Result := TRegisteredComponent(PalletteTree.Selected.Data);
|
||||||
end else if InheritanceTree.IsVisible then
|
end
|
||||||
|
else if InheritanceTree.IsVisible then
|
||||||
begin
|
begin
|
||||||
if Assigned(InheritanceTree.Selected) then
|
if Assigned(InheritanceTree.Selected) then
|
||||||
Result := TRegisteredComponent(InheritanceTree.Selected.Data);
|
Result := TRegisteredComponent(InheritanceTree.Selected.Data);
|
||||||
@ -272,38 +272,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.AddSelectedComponent(AComponent: TRegisteredComponent);
|
|
||||||
// Add the DblClicked component to the current designed form
|
|
||||||
var
|
|
||||||
TypeClass: TComponentClass;
|
|
||||||
X, Y: integer;
|
|
||||||
DisableAutoSize: Boolean;
|
|
||||||
ParentComponent: TComponent;
|
|
||||||
NewComponent: TComponent;
|
|
||||||
begin
|
|
||||||
if not Assigned(AComponent) then Exit;
|
|
||||||
if not Assigned(FormEditingHook) then Exit;
|
|
||||||
//TComponentPalette(IDEComponentPalette).Selected := AComponent;
|
|
||||||
|
|
||||||
TypeClass:=AComponent.ComponentClass;
|
|
||||||
ParentComponent:=FormEditingHook.GetDefaultComponentParent(TypeClass);
|
|
||||||
if ParentComponent=nil then exit;
|
|
||||||
|
|
||||||
//Would be lovely if it would only select the component as if it was
|
|
||||||
//clicked in the palette bar so you can drop it on your own position.
|
|
||||||
if not FormEditingHook.GetDefaultComponentPosition(TypeClass,ParentComponent,X,Y)
|
|
||||||
then exit;
|
|
||||||
|
|
||||||
DisableAutoSize:=true;
|
|
||||||
NewComponent:=FormEditingHook.CreateComponent(ParentComponent,TypeClass,'',
|
|
||||||
X,Y,0,0,DisableAutoSize);
|
|
||||||
if Assigned(NewComponent) then begin
|
|
||||||
if DisableAutoSize and (NewComponent is TControl) then
|
|
||||||
TControl(NewComponent).EnableAutoSizing;
|
|
||||||
GlobalDesignHook.PersistentAdded(NewComponent,true);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.ComponentsListboxDrawItem(Control: TWinControl;
|
procedure TComponentListForm.ComponentsListboxDrawItem(Control: TWinControl;
|
||||||
Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
||||||
var
|
var
|
||||||
@ -383,7 +351,17 @@ end;
|
|||||||
procedure TComponentListForm.ComponentsDblClick(Sender: TObject);
|
procedure TComponentListForm.ComponentsDblClick(Sender: TObject);
|
||||||
// This is used for all 3 lists / treeviews
|
// This is used for all 3 lists / treeviews
|
||||||
begin
|
begin
|
||||||
AddSelectedComponent(GetSelectedComponent);
|
OKButtonClick(nil); // Select and close this form
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentListForm.ComponentsClick(Sender: TObject);
|
||||||
|
// This is used for all 3 lists / treeviews
|
||||||
|
var
|
||||||
|
AComponent: TRegisteredComponent;
|
||||||
|
begin
|
||||||
|
AComponent:=GetSelectedComponent;
|
||||||
|
if AComponent<>nil then
|
||||||
|
IDEComponentPalette.Selected:=AComponent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.ComponentsListboxKeyDown(Sender: TObject;
|
procedure TComponentListForm.ComponentsListboxKeyDown(Sender: TObject;
|
||||||
@ -410,8 +388,9 @@ end;
|
|||||||
|
|
||||||
procedure TComponentListForm.PageControlChange(Sender: TObject);
|
procedure TComponentListForm.PageControlChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Assert(PageControl.PageIndex <> PrevPageIndex,
|
Assert(PageControl.PageIndex <> PrevPageIndex, Format(
|
||||||
Format('PageControl.PageIndex = PrevPageIndex = %d', [PrevPageIndex]));
|
'TComponentListForm.PageControlChange: PageControl.PageIndex = PrevPageIndex = %d',
|
||||||
|
[PrevPageIndex]));
|
||||||
case PageControl.PageIndex of
|
case PageControl.PageIndex of
|
||||||
0: begin
|
0: begin
|
||||||
ListFilterEd.Visible := True;
|
ListFilterEd.Visible := True;
|
||||||
@ -443,8 +422,7 @@ begin
|
|||||||
PrevPageIndex := PageControl.PageIndex;
|
PrevPageIndex := PageControl.PageIndex;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.FormClose(Sender: TObject;
|
procedure TComponentListForm.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||||
var CloseAction: TCloseAction);
|
|
||||||
begin
|
begin
|
||||||
// Using a dock manager...
|
// Using a dock manager...
|
||||||
if Parent<>nil then
|
if Parent<>nil then
|
||||||
@ -466,22 +444,23 @@ procedure TComponentListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift:
|
|||||||
//Close the form on escape key like every other IDE dialog does
|
//Close the form on escape key like every other IDE dialog does
|
||||||
begin
|
begin
|
||||||
if (Key=VK_ESCAPE) and (Parent=nil) then
|
if (Key=VK_ESCAPE) and (Parent=nil) then
|
||||||
Close;
|
CancelButtonClick(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.ButtonPanelOKButtonClick(Sender: TObject);
|
procedure TComponentListForm.OKButtonClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
AComponent: TRegisteredComponent;
|
AComponent: TRegisteredComponent;
|
||||||
begin
|
begin
|
||||||
AComponent:=GetSelectedComponent;
|
AComponent := GetSelectedComponent;
|
||||||
if AComponent<>nil then begin
|
if AComponent<>nil then begin
|
||||||
IDEComponentPalette.Selected:=AComponent;
|
IDEComponentPalette.Selected := AComponent;
|
||||||
Close;
|
Close;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.CloseButtonClick(Sender: TObject);
|
procedure TComponentListForm.CancelButtonClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
IDEComponentPalette.Selected := nil;
|
||||||
Close;
|
Close;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -473,6 +473,7 @@
|
|||||||
<Filename Value="frames/compiler_path_options.pas"/>
|
<Filename Value="frames/compiler_path_options.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="CompilerPathOptionsFrame"/>
|
<ComponentName Value="CompilerPathOptionsFrame"/>
|
||||||
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Frame"/>
|
<ResourceBaseClass Value="Frame"/>
|
||||||
<UnitName Value="compiler_path_options"/>
|
<UnitName Value="compiler_path_options"/>
|
||||||
</Unit59>
|
</Unit59>
|
||||||
|
@ -264,6 +264,7 @@ resourcestring
|
|||||||
lisKMSelectLineEnd = 'Select Line End';
|
lisKMSelectLineEnd = 'Select Line End';
|
||||||
lisKMSelectPageTop = 'Select Page Top';
|
lisKMSelectPageTop = 'Select Page Top';
|
||||||
lisKMSelectPageBottom = 'Select Page Bottom';
|
lisKMSelectPageBottom = 'Select Page Bottom';
|
||||||
|
lisUseSelected = 'Use Selected';
|
||||||
lisMenuSelect = 'Select';
|
lisMenuSelect = 'Select';
|
||||||
lisMenuSelectAll = 'Select All';
|
lisMenuSelectAll = 'Select All';
|
||||||
lisCheckAll = 'Check All';
|
lisCheckAll = 'Check All';
|
||||||
|
Loading…
Reference in New Issue
Block a user