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

View File

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