mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 13:39:36 +02:00
IDE: Component List improvements. Use FilterEdit components and customdraw the first list
git-svn-id: trunk@35009 -
This commit is contained in:
parent
e0ffd40eed
commit
275923bb94
@ -1,15 +1,14 @@
|
|||||||
object ComponentListForm: TComponentListForm
|
object ComponentListForm: TComponentListForm
|
||||||
Left = 542
|
Left = 320
|
||||||
Height = 556
|
Height = 556
|
||||||
Top = 269
|
Top = 307
|
||||||
Width = 224
|
Width = 338
|
||||||
ActiveControl = PatternEdit
|
ActiveControl = ListFilterEd
|
||||||
Caption = 'Components'
|
Caption = 'Components'
|
||||||
ClientHeight = 556
|
ClientHeight = 556
|
||||||
ClientWidth = 224
|
ClientWidth = 338
|
||||||
KeyPreview = True
|
KeyPreview = True
|
||||||
OnKeyDown = FormKeyDown
|
OnKeyDown = FormKeyDown
|
||||||
OnShow = FormShow
|
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '0.9.31'
|
LCLVersion = '0.9.31'
|
||||||
object PageControl: TPageControl
|
object PageControl: TPageControl
|
||||||
@ -20,158 +19,175 @@ object ComponentListForm: TComponentListForm
|
|||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
AnchorSideBottom.Control = ButtonPanel
|
AnchorSideBottom.Control = ButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 452
|
Height = 453
|
||||||
Top = 57
|
Top = 53
|
||||||
Width = 212
|
Width = 326
|
||||||
ActivePage = TabSheetListBox
|
ActivePage = TabSheetListBox
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
TabIndex = 0
|
TabIndex = 0
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
|
OnChange = PageControlChange
|
||||||
object TabSheetListBox: TTabSheet
|
object TabSheetListBox: TTabSheet
|
||||||
Caption = 'List'
|
Caption = 'List'
|
||||||
ClientHeight = 425
|
ClientHeight = 419
|
||||||
ClientWidth = 208
|
ClientWidth = 322
|
||||||
object Panel7: TPanel
|
object Panel7: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 425
|
Height = 419
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 208
|
Width = 322
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
BorderWidth = 5
|
BorderWidth = 5
|
||||||
ClientHeight = 425
|
ClientHeight = 419
|
||||||
ClientWidth = 208
|
ClientWidth = 322
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object ListboxComponents: TListBox
|
object ComponentsListbox: TListBox
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 415
|
Height = 409
|
||||||
Top = 5
|
Top = 5
|
||||||
Width = 198
|
Width = 312
|
||||||
Align = alClient
|
Align = alClient
|
||||||
ItemHeight = 0
|
ItemHeight = 0
|
||||||
OnDblClick = ListboxComponentsDblClick
|
OnDblClick = ComponentsListboxDblClick
|
||||||
OnKeyDown = ListboxComponentsKeyDown
|
OnDrawItem = ComponentsListboxDrawItem
|
||||||
|
OnKeyDown = ComponentsListboxKeyDown
|
||||||
Sorted = True
|
Sorted = True
|
||||||
|
Style = lbOwnerDrawFixed
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object TabSheetPaletteTree: TTabSheet
|
object TabSheetPaletteTree: TTabSheet
|
||||||
Caption = 'Palette'
|
Caption = 'Palette'
|
||||||
ClientHeight = 425
|
ClientHeight = 419
|
||||||
ClientWidth = 208
|
ClientWidth = 322
|
||||||
object Panel5: TPanel
|
object Panel5: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 425
|
Height = 419
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 208
|
Width = 322
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
BorderWidth = 5
|
BorderWidth = 5
|
||||||
ClientHeight = 425
|
ClientHeight = 419
|
||||||
ClientWidth = 208
|
ClientWidth = 322
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object TreePallette: TTreeView
|
object PalletteTree: TTreeView
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 415
|
Height = 409
|
||||||
Top = 5
|
Top = 5
|
||||||
Width = 198
|
Width = 312
|
||||||
Align = alClient
|
Align = alClient
|
||||||
DefaultItemHeight = 19
|
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
ShowLines = False
|
ShowLines = False
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnDblClick = TreePalletteDblClick
|
OnDblClick = PalletteTreeDblClick
|
||||||
OnKeyDown = TreePalletteKeyDown
|
OnKeyDown = PalletteTreeKeyDown
|
||||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw]
|
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object TabSheetInheritance: TTabSheet
|
object TabSheetInheritance: TTabSheet
|
||||||
Caption = 'Inheritance'
|
Caption = 'Inheritance'
|
||||||
ClientHeight = 425
|
ClientHeight = 410
|
||||||
ClientWidth = 208
|
ClientWidth = 208
|
||||||
object Panel6: TPanel
|
object Panel6: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 425
|
Height = 410
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 208
|
Width = 208
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
BorderWidth = 5
|
BorderWidth = 5
|
||||||
ClientHeight = 425
|
ClientHeight = 410
|
||||||
ClientWidth = 208
|
ClientWidth = 208
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object TreeInheritance: TTreeView
|
object InheritanceTree: TTreeView
|
||||||
Left = 5
|
Left = 5
|
||||||
Height = 415
|
Height = 400
|
||||||
Top = 5
|
Top = 5
|
||||||
Width = 198
|
Width = 198
|
||||||
Align = alClient
|
Align = alClient
|
||||||
DefaultItemHeight = 19
|
|
||||||
ReadOnly = True
|
ReadOnly = True
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnDblClick = TreeInheritanceDblClick
|
OnDblClick = InheritanceTreeDblClick
|
||||||
OnKeyDown = TreeInheritanceKeyDown
|
OnKeyDown = InheritanceTreeKeyDown
|
||||||
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw]
|
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object Panel3: TPanel
|
object Panel3: TPanel
|
||||||
AnchorSideLeft.Control = Owner
|
|
||||||
AnchorSideTop.Control = Owner
|
|
||||||
AnchorSideRight.Control = Owner
|
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 51
|
Height = 47
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 224
|
Width = 338
|
||||||
Anchors = [akTop, akLeft, akRight]
|
Anchors = [akTop, akLeft, akRight]
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
BorderWidth = 8
|
BorderWidth = 8
|
||||||
ClientHeight = 51
|
ClientHeight = 47
|
||||||
ClientWidth = 224
|
ClientWidth = 338
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object LabelSearch: TLabel
|
object LabelSearch: TLabel
|
||||||
AnchorSideLeft.Control = Panel3
|
AnchorSideLeft.Control = Panel3
|
||||||
AnchorSideTop.Control = Panel3
|
AnchorSideTop.Control = Panel3
|
||||||
Left = 14
|
Left = 14
|
||||||
Height = 18
|
Height = 19
|
||||||
Top = 14
|
Top = 14
|
||||||
Width = 80
|
Width = 91
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = 'LabelSearch'
|
Caption = 'LabelSearch'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object PatternEdit: TEdit
|
object ListFilterEd: TListFilterEdit
|
||||||
AnchorSideLeft.Control = LabelSearch
|
AnchorSideLeft.Control = LabelSearch
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = Panel3
|
AnchorSideTop.Control = LabelSearch
|
||||||
AnchorSideRight.Control = Panel3
|
AnchorSideTop.Side = asrCenter
|
||||||
AnchorSideRight.Side = asrBottom
|
Left = 111
|
||||||
Left = 100
|
Height = 28
|
||||||
Height = 23
|
Top = 9
|
||||||
Top = 14
|
Width = 169
|
||||||
Width = 110
|
ButtonWidth = 23
|
||||||
Anchors = [akTop, akLeft, akRight]
|
NumGlyphs = 0
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Left = 5
|
||||||
OnChange = PatternEditChange
|
MaxLength = 0
|
||||||
OnKeyDown = PatternEditKeyDown
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
FilteredListbox = ComponentsListbox
|
||||||
|
end
|
||||||
|
object TreeFilterEd: TTreeFilterEdit
|
||||||
|
AnchorSideLeft.Control = LabelSearch
|
||||||
|
AnchorSideLeft.Side = asrBottom
|
||||||
|
AnchorSideTop.Control = LabelSearch
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 111
|
||||||
|
Height = 28
|
||||||
|
Top = 9
|
||||||
|
Width = 169
|
||||||
|
ButtonWidth = 23
|
||||||
|
NumGlyphs = 0
|
||||||
|
BorderSpacing.Left = 5
|
||||||
|
MaxLength = 0
|
||||||
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object ButtonPanel: TButtonPanel
|
object ButtonPanel: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 35
|
Height = 38
|
||||||
Top = 515
|
Top = 512
|
||||||
Width = 212
|
Width = 326
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
|
OKButton.DefaultCaption = True
|
||||||
HelpButton.Name = 'HelpButton'
|
HelpButton.Name = 'HelpButton'
|
||||||
|
HelpButton.DefaultCaption = True
|
||||||
CloseButton.Name = 'CloseButton'
|
CloseButton.Name = 'CloseButton'
|
||||||
|
CloseButton.DefaultCaption = True
|
||||||
CancelButton.Name = 'CancelButton'
|
CancelButton.Name = 'CancelButton'
|
||||||
|
CancelButton.DefaultCaption = True
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
ShowButtons = [pbClose]
|
ShowButtons = [pbClose]
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
{
|
{
|
||||||
/***************************************************************************
|
|
||||||
findcomponent.pas
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
* *
|
* *
|
||||||
* This source is free software; you can redistribute it and/or modify *
|
* This source is free software; you can redistribute it and/or modify *
|
||||||
@ -26,11 +19,11 @@
|
|||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
Author: Marius
|
Author: Marius
|
||||||
|
Modified by Juha Manninen
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
A dialog to quickly find components and create the found components
|
A dialog to quickly find components and create the found components
|
||||||
directly on the designed form. This avoids a lot of scrolling in my
|
directly on the designed form.
|
||||||
already overfull palette (i love having the lazarus sources!).
|
|
||||||
}
|
}
|
||||||
unit ComponentList;
|
unit ComponentList;
|
||||||
|
|
||||||
@ -39,55 +32,49 @@ unit ComponentList;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLType, Forms, Controls, Graphics, StdCtrls, ExtCtrls,
|
||||||
StdCtrls, Buttons, FormEditingIntf, LazarusIDEStrConsts, ExtCtrls, ComCtrls,
|
ComCtrls, ButtonPanel, LazarusIDEStrConsts, ComponentReg, PackageDefs,
|
||||||
ComponentPalette, ComponentReg, PackageDefs, ExtDlgs, FormEditor, PropEdits,
|
FormEditingIntf, PropEdits, ListFilterEdit, TreeFilterEdit, fgl;
|
||||||
LCLType, Menus, ButtonPanel, IDEWindowIntf;
|
|
||||||
|
|
||||||
|
|
||||||
const
|
|
||||||
ComponentListFormName = 'ComponentList';
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
TRegisteredCompList = specialize TFPGList<TRegisteredComponent>;
|
||||||
|
|
||||||
{ TComponentListForm }
|
{ TComponentListForm }
|
||||||
|
|
||||||
TComponentListForm = class(TForm)
|
TComponentListForm = class(TForm)
|
||||||
ButtonPanel: TButtonPanel;
|
ButtonPanel: TButtonPanel;
|
||||||
LabelSearch: TLabel;
|
LabelSearch: TLabel;
|
||||||
ListboxComponents: TListBox;
|
ComponentsListbox: TListBox;
|
||||||
|
ListFilterEd: TListFilterEdit;
|
||||||
PageControl: TPageControl;
|
PageControl: TPageControl;
|
||||||
Panel3: TPanel;
|
Panel3: TPanel;
|
||||||
Panel5: TPanel;
|
Panel5: TPanel;
|
||||||
Panel6: TPanel;
|
Panel6: TPanel;
|
||||||
Panel7: TPanel;
|
Panel7: TPanel;
|
||||||
PatternEdit: TEdit;
|
|
||||||
TabSheetInheritance: TTabSheet;
|
TabSheetInheritance: TTabSheet;
|
||||||
TabSheetListBox: TTabSheet;
|
TabSheetListBox: TTabSheet;
|
||||||
TabSheetPaletteTree: TTabSheet;
|
TabSheetPaletteTree: TTabSheet;
|
||||||
TreeInheritance: TTreeView;
|
InheritanceTree: TTreeView;
|
||||||
TreePallette: TTreeView;
|
PalletteTree: TTreeView;
|
||||||
procedure FormShow(Sender: TObject);
|
TreeFilterEd: TTreeFilterEdit;
|
||||||
procedure ListboxComponentsDblClick(Sender: TObject);
|
procedure ComponentsListboxDblClick(Sender: TObject);
|
||||||
procedure ListboxComponentsKeyDown(Sender: TObject; var Key: Word;
|
procedure ComponentsListboxDrawItem(Control: TWinControl; Index: Integer;
|
||||||
Shift: TShiftState);
|
ARect: TRect; State: TOwnerDrawState);
|
||||||
procedure PatternEditKeyDown(Sender: TObject; var Key: Word;
|
procedure ComponentsListboxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
Shift: TShiftState);
|
procedure InheritanceTreeDblClick ( Sender: TObject ) ;
|
||||||
procedure TreeInheritanceDblClick ( Sender: TObject ) ;
|
procedure InheritanceTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure TreeInheritanceKeyDown(Sender: TObject; var Key: Word;
|
procedure PageControlChange(Sender: TObject);
|
||||||
Shift: TShiftState);
|
procedure PalletteTreeDblClick(Sender: TObject);
|
||||||
procedure TreePalletteDblClick(Sender: TObject);
|
procedure PalletteTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure TreePalletteKeyDown(Sender: TObject; var Key: Word;
|
|
||||||
Shift: TShiftState);
|
|
||||||
procedure UpdateComponentSelection(Sender: TObject);
|
procedure UpdateComponentSelection(Sender: TObject);
|
||||||
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure PatternEditChange(Sender: TObject);
|
|
||||||
procedure Timer1Timer(Sender: TObject);
|
|
||||||
private
|
private
|
||||||
FTimer: TTimer;
|
PrevPageIndex: Integer;
|
||||||
Processing: boolean;
|
Processing: boolean;
|
||||||
FComponentList: TFPList;
|
FComponentList: TRegisteredCompList;
|
||||||
procedure FindAllLazarusComponents;
|
procedure FindAllLazarusComponents;
|
||||||
procedure AddSelectedComponent(AComponent: TRegisteredComponent);
|
procedure AddSelectedComponent(AComponent: TRegisteredComponent);
|
||||||
procedure SetFocusToDataList;
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
@ -105,13 +92,9 @@ implementation
|
|||||||
constructor TComponentListForm.Create(AOwner: TComponent);
|
constructor TComponentListForm.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FTimer := TTimer.Create(nil);
|
FComponentList := TRegisteredCompList.Create;
|
||||||
FTimer.Interval := 500;
|
|
||||||
FTimer.Enabled := false;
|
|
||||||
FTimer.OnTimer := @Timer1Timer;
|
|
||||||
FComponentList := TFPList.Create;
|
|
||||||
|
|
||||||
ButtonPanel.CloseButton.Cancel := True;
|
ButtonPanel.CloseButton.Cancel := True;
|
||||||
|
ComponentsListBox.ItemHeight:=ComponentPaletteImageHeight + 2;
|
||||||
|
|
||||||
//Translations..
|
//Translations..
|
||||||
LabelSearch.Caption := lisMenuFind;
|
LabelSearch.Caption := lisMenuFind;
|
||||||
@ -119,21 +102,21 @@ begin
|
|||||||
TabSheetListBox.Caption := lisCmpLstList;
|
TabSheetListBox.Caption := lisCmpLstList;
|
||||||
TabSheetPaletteTree.Caption := lisCmpLstPalette;
|
TabSheetPaletteTree.Caption := lisCmpLstPalette;
|
||||||
TabSheetInheritance.Caption := lisCmpLstInheritance;
|
TabSheetInheritance.Caption := lisCmpLstInheritance;
|
||||||
|
|
||||||
//PLEASE add a defaultpage property in TPagecontrol
|
//PLEASE add a defaultpage property in TPagecontrol
|
||||||
PageControl.ActivePage := TabSheetListBox;
|
PageControl.ActivePage := TabSheetListBox;
|
||||||
|
PrevPageIndex := 0;
|
||||||
|
TreeFilterEd.Visible := False;
|
||||||
|
|
||||||
FindAllLazarusComponents;
|
FindAllLazarusComponents;
|
||||||
UpdateComponentSelection(nil);
|
UpdateComponentSelection(nil);
|
||||||
IDEDialogLayoutList.ApplyLayout(Self);
|
ListFilterEd.InvalidateFilter;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TComponentListForm.Destroy;
|
destructor TComponentListForm.Destroy;
|
||||||
begin
|
begin
|
||||||
IDEDialogLayoutList.SaveLayout(Self);
|
|
||||||
ComponentListForm := nil;
|
ComponentListForm := nil;
|
||||||
FComponentList.Free;
|
FComponentList.Free;
|
||||||
FTimer.Free;
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -144,19 +127,18 @@ var
|
|||||||
APage: TBaseComponentPage;
|
APage: TBaseComponentPage;
|
||||||
i, j: Integer;
|
i, j: Integer;
|
||||||
begin
|
begin
|
||||||
if Assigned(IDEComponentPalette)
|
if Assigned(IDEComponentPalette) then
|
||||||
then begin
|
begin
|
||||||
for i := 0 to IDEComponentPalette.Count-1 do
|
for i := 0 to IDEComponentPalette.Count-1 do
|
||||||
begin
|
begin
|
||||||
APage := IDEComponentPalette.Pages[i];
|
APage := IDEComponentPalette.Pages[i];
|
||||||
if not APage.Visible then continue;
|
if APage.Visible then
|
||||||
for j := 0 to APage.Count-1 do
|
for j := 0 to APage.Count-1 do
|
||||||
begin
|
begin
|
||||||
AComponent := APage.Items[j];
|
AComponent := APage.Items[j];
|
||||||
if not AComponent.Visible then continue;
|
if AComponent.Visible and (AComponent.PageName<>'') then
|
||||||
if AComponent.PageName='' then continue;
|
FComponentList.Add(AComponent);
|
||||||
FComponentList.Add(AComponent);
|
end;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -165,116 +147,103 @@ procedure TComponentListForm.UpdateComponentSelection(Sender: TObject);
|
|||||||
//Apply the filter and fill the three tabsheets
|
//Apply the filter and fill the three tabsheets
|
||||||
var
|
var
|
||||||
AComponent: TRegisteredComponent;
|
AComponent: TRegisteredComponent;
|
||||||
AFilter, AClassName: string;
|
AClassName: string;
|
||||||
AClassList, List: TStringlist;
|
AClassList, List: TStringlist;
|
||||||
i, j, AIndex: Integer;
|
i, j, AIndex: Integer;
|
||||||
ANode: TTreeNode;
|
ANode: TTreeNode;
|
||||||
AClass: TClass;
|
AClass: TClass;
|
||||||
begin
|
begin
|
||||||
if Processing
|
if Processing then exit;
|
||||||
then exit;
|
|
||||||
Processing := true;
|
Processing := true;
|
||||||
FTimer.Enabled := false;
|
|
||||||
Screen.Cursor := crHourGlass;
|
Screen.Cursor := crHourGlass;
|
||||||
try
|
try
|
||||||
AFilter := UpperCase(PatternEdit.Text);
|
|
||||||
|
|
||||||
//First tabsheet (ListboxComponents)
|
//First tabsheet (ComponentsListbox)
|
||||||
ListboxComponents.Items.BeginUpdate;
|
ComponentsListbox.Items.BeginUpdate;
|
||||||
try
|
try
|
||||||
ListboxComponents.Items.Clear;
|
ComponentsListbox.Items.Clear;
|
||||||
for i := 0 to FComponentList.Count-1 do
|
for i := 0 to FComponentList.Count-1 do
|
||||||
begin
|
begin
|
||||||
AComponent := TRegisteredComponent(FComponentList[i]);
|
AComponent := FComponentList[i];
|
||||||
AClassName := AComponent.ComponentClass.ClassName;
|
AClassName := AComponent.ComponentClass.ClassName;
|
||||||
if (AFilter='') or (Pos(AFilter, UpperCase(AClassName))>0)
|
ListFilterEd.Data.AddObject(AClassName, AComponent);
|
||||||
then ListboxComponents.Items.AddObject(AClassName, AComponent);
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
ListboxComponents.Items.EndUpdate;
|
ComponentsListbox.Items.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//Second tabsheet (palette layout)
|
//Second tabsheet (palette layout)
|
||||||
TreePallette.BeginUpdate;
|
PalletteTree.BeginUpdate;
|
||||||
try
|
try
|
||||||
TreePallette.Items.Clear;
|
PalletteTree.Items.Clear;
|
||||||
for i := 0 to FComponentList.Count-1 do
|
for i := 0 to FComponentList.Count-1 do
|
||||||
begin
|
begin
|
||||||
AComponent := TRegisteredComponent(FComponentList[i]);
|
AComponent := FComponentList[i];
|
||||||
AClassName := AComponent.ComponentClass.ClassName;
|
AClassName := AComponent.ComponentClass.ClassName;
|
||||||
if (AFilter='') or (Pos(AFilter, UpperCase(AClassName))>0)
|
//find out parent node
|
||||||
then begin
|
ANode := PalletteTree.Items.FindTopLvlNode(AComponent.PageName);
|
||||||
//find out parent node
|
if ANode = nil then
|
||||||
ANode := TreePallette.Items.FindTopLvlNode(AComponent.PageName);
|
ANode := PalletteTree.Items.AddChild(nil, AComponent.PageName);
|
||||||
if ANode = nil
|
//add the item
|
||||||
then ANode := TreePallette.Items.AddChild(nil, AComponent.PageName);
|
ANode := PalletteTree.Items.AddChildObject(ANode, AClassName, AComponent);
|
||||||
//add the item
|
|
||||||
TreePallette.Items.AddChildObject(ANode, AClassName, AComponent);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
TreePallette.FullExpand;
|
PalletteTree.FullExpand;
|
||||||
finally
|
finally
|
||||||
TreePallette.EndUpdate;
|
PalletteTree.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
//Third tabsheet (component inheritence)
|
//Third tabsheet (component inheritence)
|
||||||
List := TStringlist.Create;
|
List := TStringlist.Create;
|
||||||
AClassList:= TStringlist.Create;
|
AClassList:= TStringlist.Create;
|
||||||
TreeInheritance.Items.BeginUpdate;
|
InheritanceTree.Items.BeginUpdate;
|
||||||
try
|
try
|
||||||
TreeInheritance.Items.Clear;
|
InheritanceTree.Items.Clear;
|
||||||
AClassList.Sorted := true;
|
AClassList.Sorted := true;
|
||||||
AClassList.CaseSensitive := false;
|
AClassList.CaseSensitive := false;
|
||||||
AClassList.Duplicates := dupIgnore;
|
AClassList.Duplicates := dupIgnore;
|
||||||
|
|
||||||
for i := 0 to FComponentList.Count-1 do
|
for i := 0 to FComponentList.Count-1 do
|
||||||
begin
|
begin
|
||||||
AComponent := TRegisteredComponent(FComponentList[i]);
|
AComponent := FComponentList[i];
|
||||||
AClassName := AComponent.ComponentClass.ClassName;
|
AClassName := AComponent.ComponentClass.ClassName;
|
||||||
if (AFilter='') or (Pos(AFilter, UpperCase(AClassName))>0)then
|
// walk down to parent, stop on tcomponent, since components are at least
|
||||||
|
// a tcomponent descendant
|
||||||
|
List.Clear;
|
||||||
|
AClass := AComponent.ComponentClass;
|
||||||
|
while (AClass.ClassInfo <> nil) and (AClass.ClassType <> TComponent.ClassType) do
|
||||||
begin
|
begin
|
||||||
|
List.AddObject(AClass.ClassName, TObject(AClass));
|
||||||
|
AClass := AClass.ClassParent;
|
||||||
|
end;
|
||||||
|
|
||||||
// walk down to parent, stop on tcomponent, since components are at least
|
//build the tree
|
||||||
// a tcomponent descendant
|
for j := List.Count - 1 downto 0 do
|
||||||
List.Clear;
|
begin
|
||||||
AClass := AComponent.ComponentClass;
|
AClass := TClass(List.Objects[j]);
|
||||||
while (AClass.ClassInfo <> nil) and (AClass.ClassType <> TComponent.ClassType) do
|
AClassName := List[j];
|
||||||
begin
|
|
||||||
List.AddObject(AClass.ClassName, TObject(AClass));
|
|
||||||
AClass := AClass.ClassParent;
|
|
||||||
end;
|
|
||||||
|
|
||||||
//build the tree
|
if not AClassList.Find(AClassName, AIndex)
|
||||||
for j := List.Count - 1 downto 0 do
|
then begin
|
||||||
begin
|
//find out parent position
|
||||||
AClass := TClass(List.Objects[j]);
|
if Assigned(AClass.ClassParent) and AClassList.Find(AClass.ClassParent.ClassName, AIndex)
|
||||||
AClassName := List[j];
|
then ANode := TTreeNode(AClassList.Objects[AIndex])
|
||||||
|
else ANode := nil;
|
||||||
|
|
||||||
if not AClassList.Find(AClassName, AIndex)
|
//add the item
|
||||||
then begin
|
if AClassName <> AComponent.ComponentClass.ClassName
|
||||||
//find out parent position
|
then ANode := InheritanceTree.Items.AddChild(ANode, AClassName)
|
||||||
if Assigned(AClass.ClassParent) and AClassList.Find(AClass.ClassParent.ClassName, AIndex)
|
else ANode := InheritanceTree.Items.AddChildObject(ANode, AClassName, AComponent);
|
||||||
then ANode := TTreeNode(AClassList.Objects[AIndex])
|
AClassList.AddObject(AClassName, ANode);
|
||||||
else ANode := nil;
|
|
||||||
|
|
||||||
//add the item
|
|
||||||
if AClassName <> AComponent.ComponentClass.ClassName
|
|
||||||
then ANode := TreeInheritance.Items.AddChild(ANode, AClassName)
|
|
||||||
else ANode := TreeInheritance.Items.AddChildObject(ANode, AClassName, AComponent);
|
|
||||||
AClassList.AddObject(AClassName, ANode);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
InheritanceTree.AlphaSort;
|
||||||
TreeInheritance.AlphaSort;
|
InheritanceTree.FullExpand;
|
||||||
TreeInheritance.FullExpand;
|
|
||||||
finally
|
finally
|
||||||
List.Free;
|
List.Free;
|
||||||
AClassList.Free;
|
AClassList.Free;
|
||||||
TreeInheritance.Items.EndUpdate;
|
InheritanceTree.Items.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
@ -292,10 +261,8 @@ var
|
|||||||
ParentComponent: TComponent;
|
ParentComponent: TComponent;
|
||||||
NewComponent: TComponent;
|
NewComponent: TComponent;
|
||||||
begin
|
begin
|
||||||
if not Assigned(AComponent)
|
if not Assigned(AComponent) then Exit;
|
||||||
then Exit;
|
if not Assigned(FormEditingHook) then Exit;
|
||||||
if not Assigned(FormEditingHook)
|
|
||||||
then Exit;
|
|
||||||
//TComponentPalette(IDEComponentPalette).Selected := AComponent;
|
//TComponentPalette(IDEComponentPalette).Selected := AComponent;
|
||||||
|
|
||||||
TypeClass:=AComponent.ComponentClass;
|
TypeClass:=AComponent.ComponentClass;
|
||||||
@ -309,7 +276,7 @@ begin
|
|||||||
|
|
||||||
DisableAutoSize:=true;
|
DisableAutoSize:=true;
|
||||||
NewComponent:=FormEditingHook.CreateComponent(ParentComponent,TypeClass,'',
|
NewComponent:=FormEditingHook.CreateComponent(ParentComponent,TypeClass,'',
|
||||||
X,Y,0,0,DisableAutoSize);
|
X,Y,0,0,DisableAutoSize);
|
||||||
if Assigned(NewComponent) then begin
|
if Assigned(NewComponent) then begin
|
||||||
if DisableAutoSize and (NewComponent is TControl) then
|
if DisableAutoSize and (NewComponent is TControl) then
|
||||||
TControl(NewComponent).EnableAutoSizing;
|
TControl(NewComponent).EnableAutoSizing;
|
||||||
@ -317,124 +284,119 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.ListboxComponentsDblClick(Sender: TObject);
|
procedure TComponentListForm.ComponentsListboxDblClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
AddSelectedComponent(TRegisteredComponent(ListboxComponents.Items.Objects[ListboxComponents.ItemIndex]));
|
AddSelectedComponent(TRegisteredComponent(ComponentsListbox.Items.Objects[ComponentsListbox.ItemIndex]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.ListboxComponentsKeyDown(Sender: TObject;
|
procedure TComponentListForm.ComponentsListboxDrawItem(Control: TWinControl;
|
||||||
|
Index: Integer; ARect: TRect; State: TOwnerDrawState);
|
||||||
|
var
|
||||||
|
Comp: TRegisteredComponent;
|
||||||
|
CurStr: string;
|
||||||
|
TxtH: Integer;
|
||||||
|
CurIcon: TCustomBitmap;
|
||||||
|
IconWidth: Integer;
|
||||||
|
IconHeight: Integer;
|
||||||
|
begin
|
||||||
|
if (Index<0) or (Index>=ComponentsListBox.Items.Count) then exit;
|
||||||
|
// draw registered component
|
||||||
|
Comp:=TRegisteredComponent(ComponentsListBox.Items.Objects[Index]);
|
||||||
|
with ComponentsListBox.Canvas do begin
|
||||||
|
CurStr:=Comp.ComponentClass.ClassName;
|
||||||
|
// CurStr:=Format(lisPckEditPage,[Comp.ComponentClass.ClassName,Comp.Page.PageName]);
|
||||||
|
TxtH:=TextHeight(CurStr);
|
||||||
|
FillRect(ARect);
|
||||||
|
CurIcon:=nil;
|
||||||
|
if Comp is TPkgComponent then
|
||||||
|
CurIcon:=TPkgComponent(Comp).Icon;
|
||||||
|
if CurIcon<>nil
|
||||||
|
then begin
|
||||||
|
IconWidth:=CurIcon.Width;
|
||||||
|
IconHeight:=CurIcon.Height;
|
||||||
|
Draw(ARect.Left+(25-IconWidth) div 2,
|
||||||
|
ARect.Top+(ARect.Bottom-ARect.Top-IconHeight) div 2,
|
||||||
|
CurIcon);
|
||||||
|
end;
|
||||||
|
TextOut(ARect.Left+25,
|
||||||
|
ARect.Top+(ARect.Bottom-ARect.Top-TxtH) div 2,
|
||||||
|
CurStr);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentListForm.ComponentsListboxKeyDown(Sender: TObject;
|
||||||
var Key: Word; Shift: TShiftState);
|
var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if Key = VK_RETURN then
|
if Key = VK_RETURN then
|
||||||
if (ListboxComponents.ItemIndex >= 0) then
|
if (ComponentsListbox.ItemIndex >= 0) then
|
||||||
ListboxComponentsDblClick(Sender);
|
ComponentsListboxDblClick(Sender);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.SetFocusToDataList;
|
procedure TComponentListForm.PalletteTreeDblClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
S: String;
|
AComponent: TRegisteredComponent;
|
||||||
i: Integer;
|
|
||||||
Node: TTreeNode;
|
|
||||||
begin
|
begin
|
||||||
S := PatternEdit.Text;
|
if not Assigned(PalletteTree.Selected) then exit;
|
||||||
|
AComponent := TRegisteredComponent(PalletteTree.Selected.Data);
|
||||||
|
if not Assigned(AComponent) then exit;
|
||||||
|
AddSelectedComponent(AComponent);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentListForm.PalletteTreeKeyDown(Sender: TObject;
|
||||||
|
var Key: Word; Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
if Key = VK_RETURN then
|
||||||
|
PalletteTreeDblClick(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentListForm.InheritanceTreeDblClick(Sender:TObject);
|
||||||
|
var
|
||||||
|
AComponent: TRegisteredComponent;
|
||||||
|
begin
|
||||||
|
if not Assigned(InheritanceTree.Selected) then exit;
|
||||||
|
AComponent := TRegisteredComponent(InheritanceTree.Selected.Data);
|
||||||
|
if not Assigned(AComponent) then exit;
|
||||||
|
AddSelectedComponent(AComponent);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentListForm.InheritanceTreeKeyDown(Sender: TObject;
|
||||||
|
var Key: Word; Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
if Key = VK_RETURN then
|
||||||
|
InheritanceTreeDblClick(Sender);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TComponentListForm.PageControlChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Assert(PageControl.PageIndex <> PrevPageIndex);
|
||||||
case PageControl.PageIndex of
|
case PageControl.PageIndex of
|
||||||
0:
|
0: begin
|
||||||
begin
|
ListFilterEd.Visible := True;
|
||||||
ListBoxComponents.SetFocus;
|
ListFilterEd.SetFocus;
|
||||||
if ListBoxComponents.Items.Count > 0 then
|
ListFilterEd.Text := TreeFilterEd.Text;
|
||||||
begin
|
ListFilterEd.InvalidateFilter;
|
||||||
i := ListBoxComponents.Items.IndexOf(S);
|
TreeFilterEd.Visible := False;
|
||||||
if i < 0 then
|
|
||||||
i := 0;
|
|
||||||
ListBoxComponents.ItemIndex := i;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
1:
|
1: begin
|
||||||
begin
|
TreeFilterEd.Visible := True;
|
||||||
TreePallette.SetFocus;
|
TreeFilterEd.FilteredTreeview := PalletteTree;
|
||||||
with TreePallette do
|
TreeFilterEd.SetFocus;
|
||||||
begin
|
if PrevPageIndex = 0 then
|
||||||
if Items.Count > 0 then
|
TreeFilterEd.Text := ListFilterEd.Text;
|
||||||
begin
|
TreeFilterEd.InvalidateFilter;
|
||||||
Node := Items.FindNodeWithText(S);
|
ListFilterEd.Visible := False;
|
||||||
if Node <> nil then
|
|
||||||
Selected := Node
|
|
||||||
else
|
|
||||||
Selected := Items[0];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
2:
|
2: begin
|
||||||
begin
|
TreeFilterEd.Visible := True;
|
||||||
TreeInheritance.SetFocus;
|
TreeFilterEd.FilteredTreeview := InheritanceTree;
|
||||||
with TreeInheritance do
|
TreeFilterEd.SetFocus;
|
||||||
begin
|
if PrevPageIndex = 0 then
|
||||||
if Items.Count > 0 then
|
TreeFilterEd.Text := ListFilterEd.Text;
|
||||||
begin
|
TreeFilterEd.InvalidateFilter;
|
||||||
Node := Items.FindNodeWithText(S);
|
ListFilterEd.Visible := False;
|
||||||
if Node <> nil then
|
|
||||||
Selected := Node
|
|
||||||
else
|
|
||||||
Selected := Items[0];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
PrevPageIndex := PageControl.PageIndex;
|
||||||
|
|
||||||
procedure TComponentListForm.PatternEditKeyDown(Sender: TObject; var Key: Word;
|
|
||||||
Shift: TShiftState);
|
|
||||||
begin
|
|
||||||
if Key = VK_RETURN then
|
|
||||||
begin
|
|
||||||
Key := 0;
|
|
||||||
SetFocusToDataList;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.TreePalletteDblClick(Sender: TObject);
|
|
||||||
var
|
|
||||||
AComponent: TRegisteredComponent;
|
|
||||||
begin
|
|
||||||
if not Assigned(TreePallette.Selected)
|
|
||||||
then exit;
|
|
||||||
AComponent := TRegisteredComponent(TreePallette.Selected.Data);
|
|
||||||
if not Assigned(AComponent)
|
|
||||||
then exit;
|
|
||||||
|
|
||||||
AddSelectedComponent(AComponent);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.TreePalletteKeyDown(Sender: TObject;
|
|
||||||
var Key: Word; Shift: TShiftState);
|
|
||||||
begin
|
|
||||||
if Key = VK_RETURN then
|
|
||||||
TreePalletteDblClick(Sender);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.TreeInheritanceDblClick(Sender:TObject);
|
|
||||||
var
|
|
||||||
AComponent: TRegisteredComponent;
|
|
||||||
begin
|
|
||||||
if not Assigned(TreeInheritance.Selected)
|
|
||||||
then exit;
|
|
||||||
AComponent := TRegisteredComponent(TreeInheritance.Selected.Data);
|
|
||||||
if not Assigned(AComponent)
|
|
||||||
then exit;
|
|
||||||
AddSelectedComponent(AComponent);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.TreeInheritanceKeyDown(Sender: TObject;
|
|
||||||
var Key: Word; Shift: TShiftState);
|
|
||||||
begin
|
|
||||||
if Key = VK_RETURN then
|
|
||||||
TreeInheritanceDblClick(Sender);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.FormShow(Sender: TObject);
|
|
||||||
begin
|
|
||||||
if PatternEdit.Canfocus
|
|
||||||
then PatternEdit.SetFocus;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure TComponentListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
@ -444,17 +406,5 @@ begin
|
|||||||
Close;
|
Close;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentListForm.PatternEditChange(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//Reset for proper delay
|
|
||||||
FTimer.Enabled := false;
|
|
||||||
FTimer.Enabled := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TComponentListForm.Timer1Timer(Sender: TObject);
|
|
||||||
begin
|
|
||||||
UpdateComponentSelection(nil);
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user