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