IDE, ComponentList: Reorder and combine some methods. No functional changes.

git-svn-id: trunk@38603 -
This commit is contained in:
juha 2012-09-09 19:29:10 +00:00
parent f59a711290
commit bc63059885
2 changed files with 89 additions and 103 deletions

View File

@ -1,7 +1,7 @@
object ComponentListForm: TComponentListForm object ComponentListForm: TComponentListForm
Left = 320 Left = 390
Height = 556 Height = 556
Top = 159 Top = 158
Width = 338 Width = 338
ActiveControl = ListFilterEd ActiveControl = ListFilterEd
Caption = 'Components' Caption = 'Components'
@ -20,8 +20,8 @@ object ComponentListForm: TComponentListForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel AnchorSideBottom.Control = ButtonPanel
Left = 1 Left = 1
Height = 481 Height = 475
Top = 27 Top = 30
Width = 336 Width = 336
ActivePage = TabSheetListBox ActivePage = TabSheetListBox
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
@ -31,63 +31,61 @@ object ComponentListForm: TComponentListForm
OnChange = PageControlChange OnChange = PageControlChange
object TabSheetListBox: TTabSheet object TabSheetListBox: TTabSheet
Caption = 'List' Caption = 'List'
ClientHeight = 454 ClientHeight = 442
ClientWidth = 332 ClientWidth = 332
object Panel7: TPanel object Panel7: TPanel
Left = 0 Left = 0
Height = 454 Height = 442
Top = 0 Top = 0
Width = 332 Width = 332
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
BorderWidth = 2 BorderWidth = 2
ClientHeight = 454 ClientHeight = 442
ClientWidth = 332 ClientWidth = 332
TabOrder = 0 TabOrder = 0
object ComponentsListbox: TListBox object ComponentsListbox: TListBox
Left = 2 Left = 2
Height = 450 Height = 438
Top = 2 Top = 2
Width = 328 Width = 328
Align = alClient Align = alClient
ItemHeight = 0 ItemHeight = 0
OnDblClick = ComponentsListboxDblClick OnDblClick = ComponentsDblClick
OnDrawItem = ComponentsListboxDrawItem OnDrawItem = ComponentsListboxDrawItem
OnKeyDown = ComponentsListboxKeyDown OnKeyDown = ComponentsListboxKeyDown
ScrollWidth = 326
Sorted = True Sorted = True
Style = lbOwnerDrawFixed Style = lbOwnerDrawFixed
TabOrder = 0 TabOrder = 0
TopIndex = -1
end end
end end
end end
object TabSheetPaletteTree: TTabSheet object TabSheetPaletteTree: TTabSheet
Caption = 'Palette' Caption = 'Palette'
ClientHeight = 454 ClientHeight = 442
ClientWidth = 332 ClientWidth = 332
object Panel5: TPanel object Panel5: TPanel
Left = 0 Left = 0
Height = 419 Height = 442
Top = 0 Top = 0
Width = 322 Width = 332
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
BorderWidth = 5 BorderWidth = 5
ClientHeight = 419 ClientHeight = 442
ClientWidth = 322 ClientWidth = 332
TabOrder = 0 TabOrder = 0
object PalletteTree: TTreeView object PalletteTree: TTreeView
Left = 5 Left = 5
Height = 409 Height = 432
Top = 5 Top = 5
Width = 312 Width = 322
Align = alClient Align = alClient
ReadOnly = True ReadOnly = True
ShowLines = False ShowLines = False
TabOrder = 0 TabOrder = 0
OnCustomDrawItem = TreeCustomDrawItem OnCustomDrawItem = TreeCustomDrawItem
OnDblClick = PalletteTreeDblClick OnDblClick = ComponentsDblClick
OnKeyDown = PalletteTreeKeyDown OnKeyDown = PalletteTreeKeyDown
Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw] Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw]
end end
@ -95,29 +93,29 @@ object ComponentListForm: TComponentListForm
end end
object TabSheetInheritance: TTabSheet object TabSheetInheritance: TTabSheet
Caption = 'Inheritance' Caption = 'Inheritance'
ClientHeight = 454 ClientHeight = 442
ClientWidth = 332 ClientWidth = 332
object Panel6: TPanel object Panel6: TPanel
Left = 0 Left = 0
Height = 410 Height = 442
Top = 0 Top = 0
Width = 208 Width = 332
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
BorderWidth = 5 BorderWidth = 5
ClientHeight = 410 ClientHeight = 442
ClientWidth = 208 ClientWidth = 332
TabOrder = 0 TabOrder = 0
object InheritanceTree: TTreeView object InheritanceTree: TTreeView
Left = 5 Left = 5
Height = 400 Height = 432
Top = 5 Top = 5
Width = 198 Width = 322
Align = alClient Align = alClient
ReadOnly = True ReadOnly = True
TabOrder = 0 TabOrder = 0
OnCustomDrawItem = TreeCustomDrawItem OnCustomDrawItem = TreeCustomDrawItem
OnDblClick = InheritanceTreeDblClick OnDblClick = ComponentsDblClick
OnKeyDown = InheritanceTreeKeyDown OnKeyDown = InheritanceTreeKeyDown
Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw] Options = [tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoNoDoubleClickExpand, tvoThemedDraw]
end end
@ -127,22 +125,22 @@ object ComponentListForm: TComponentListForm
object Panel3: TPanel object Panel3: TPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 1 Left = 1
Height = 26 Height = 29
Top = 0 Top = 0
Width = 338 Width = 338
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoSize = True AutoSize = True
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 26 ClientHeight = 29
ClientWidth = 338 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 = 6 Left = 6
Height = 14 Height = 17
Top = 6 Top = 6
Width = 71 Width = 79
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'LabelSearch' Caption = 'LabelSearch'
ParentColor = False ParentColor = False
@ -152,15 +150,14 @@ object ComponentListForm: TComponentListForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = LabelSearch AnchorSideTop.Control = LabelSearch
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 83 Left = 91
Height = 23 Height = 25
Top = 2 Top = 2
Width = 169 Width = 169
UseFormActivate = True UseFormActivate = True
ButtonWidth = 23 ButtonWidth = 23
NumGlyphs = 1 NumGlyphs = 1
BorderSpacing.Left = 5 BorderSpacing.Left = 5
Font.Color = clBtnShadow
MaxLength = 0 MaxLength = 0
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
@ -171,10 +168,10 @@ object ComponentListForm: TComponentListForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = LabelSearch AnchorSideTop.Control = LabelSearch
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 83 Left = 91
Height = 23 Height = 25
Top = 2 Top = 2
Width = 228 Width = 220
ButtonWidth = 23 ButtonWidth = 23
NumGlyphs = 1 NumGlyphs = 1
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -185,8 +182,8 @@ object ComponentListForm: TComponentListForm
end end
object ButtonPanel: TButtonPanel object ButtonPanel: TButtonPanel
Left = 6 Left = 6
Height = 36 Height = 39
Top = 514 Top = 511
Width = 326 Width = 326
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True

View File

@ -22,8 +22,8 @@
Modified by Juha Manninen Modified by Juha Manninen
Abstract: Abstract:
A dialog to quickly find components and create the found components A dialog to quickly find components and to add the found component
directly on the designed form. to the designed form.
} }
unit ComponentList; unit ComponentList;
@ -60,17 +60,15 @@ type
TreeFilterEd: TTreeFilterEdit; TreeFilterEd: TTreeFilterEdit;
procedure ButtonPanelOKButtonClick(Sender: TObject); procedure ButtonPanelOKButtonClick(Sender: TObject);
procedure CloseButtonClick(Sender: TObject); procedure CloseButtonClick(Sender: TObject);
procedure ComponentsListboxDblClick(Sender: TObject); procedure ComponentsDblClick(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);
procedure TreeCustomDrawItem(Sender: TCustomTreeView; procedure TreeCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
procedure ComponentsListboxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure ComponentsListboxKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure InheritanceTreeDblClick ( Sender: TObject ) ;
procedure InheritanceTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure InheritanceTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure PageControlChange(Sender: TObject); procedure PageControlChange(Sender: TObject);
procedure PalletteTreeDblClick(Sender: TObject);
procedure PalletteTreeKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure PalletteTreeKeyDown(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);
@ -137,16 +135,16 @@ begin
if ComponentsListbox.IsVisible then if ComponentsListbox.IsVisible then
begin begin
i:=ComponentsListbox.ItemIndex; i:=ComponentsListbox.ItemIndex;
if i<0 then exit; 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 not Assigned(PalletteTree.Selected) then exit; 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 not Assigned(InheritanceTree.Selected) then exit; if Assigned(InheritanceTree.Selected) then
Result := TRegisteredComponent(InheritanceTree.Selected.Data); Result := TRegisteredComponent(InheritanceTree.Selected.Data);
end; end;
end; end;
@ -306,27 +304,6 @@ begin
end; end;
end; end;
procedure TComponentListForm.ComponentsListboxDblClick(Sender: TObject);
begin
AddSelectedComponent(GetSelectedComponent);
end;
procedure TComponentListForm.ButtonPanelOKButtonClick(Sender: TObject);
var
AComponent: TRegisteredComponent;
begin
AComponent:=GetSelectedComponent;
if AComponent<>nil then begin
IDEComponentPalette.Selected:=AComponent;
Close;
end;
end;
procedure TComponentListForm.CloseButtonClick(Sender: TObject);
begin
Close;
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
@ -358,25 +335,6 @@ begin
end; end;
end; end;
procedure TComponentListForm.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
// Using a dock manager...
if Parent<>nil then
begin
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;
end;
end;
procedure TComponentListForm.TreeCustomDrawItem(Sender: TCustomTreeView; procedure TComponentListForm.TreeCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
var var
@ -422,36 +380,32 @@ begin
end; end;
end; end;
procedure TComponentListForm.ComponentsDblClick(Sender: TObject);
// This is used for all 3 lists / treeviews
begin
AddSelectedComponent(GetSelectedComponent);
end;
procedure TComponentListForm.ComponentsListboxKeyDown(Sender: TObject; 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 (ComponentsListbox.ItemIndex >= 0) then if (ComponentsListbox.ItemIndex >= 0) then
ComponentsListboxDblClick(Sender); ComponentsDblClick(Sender);
end;
procedure TComponentListForm.PalletteTreeDblClick(Sender: TObject);
begin
AddSelectedComponent(GetSelectedComponent);
end; end;
procedure TComponentListForm.PalletteTreeKeyDown(Sender: TObject; procedure TComponentListForm.PalletteTreeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState); var Key: Word; Shift: TShiftState);
begin begin
if Key = VK_RETURN then if Key = VK_RETURN then
PalletteTreeDblClick(Sender); ComponentsDblClick(Sender);
end;
procedure TComponentListForm.InheritanceTreeDblClick(Sender:TObject);
begin
AddSelectedComponent(GetSelectedComponent);
end; end;
procedure TComponentListForm.InheritanceTreeKeyDown(Sender: TObject; procedure TComponentListForm.InheritanceTreeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState); var Key: Word; Shift: TShiftState);
begin begin
if Key = VK_RETURN then if Key = VK_RETURN then
InheritanceTreeDblClick(Sender); ComponentsDblClick(Sender);
end; end;
procedure TComponentListForm.PageControlChange(Sender: TObject); procedure TComponentListForm.PageControlChange(Sender: TObject);
@ -489,6 +443,25 @@ begin
PrevPageIndex := PageControl.PageIndex; PrevPageIndex := PageControl.PageIndex;
end; end;
procedure TComponentListForm.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
begin
// Using a dock manager...
if Parent<>nil then
begin
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;
end;
end;
procedure TComponentListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure TComponentListForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
//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
@ -496,5 +469,21 @@ begin
Close; Close;
end; end;
procedure TComponentListForm.ButtonPanelOKButtonClick(Sender: TObject);
var
AComponent: TRegisteredComponent;
begin
AComponent:=GetSelectedComponent;
if AComponent<>nil then begin
IDEComponentPalette.Selected:=AComponent;
Close;
end;
end;
procedure TComponentListForm.CloseButtonClick(Sender: TObject);
begin
Close;
end;
end. end.