IDE: Notify component list of changed selection using a handler.

git-svn-id: trunk@48313 -
This commit is contained in:
juha 2015-03-12 23:02:00 +00:00
parent b0023622ae
commit 5e4005ece3

View File

@ -85,9 +85,10 @@ type
FClassList: TStringList; FClassList: TStringList;
FKeepSelected: Boolean; FKeepSelected: Boolean;
procedure ClearSelection; procedure ClearSelection;
procedure SelectionWasChanged;
procedure ComponentWasAdded; procedure ComponentWasAdded;
procedure DoComponentInheritence(Comp: TRegisteredComponent); procedure DoComponentInheritence(Comp: TRegisteredComponent);
procedure UpdateComponentSelection; procedure UpdateComponents;
procedure UpdateButtonState; procedure UpdateButtonState;
protected protected
procedure UpdateShowing; override; procedure UpdateShowing; override;
@ -129,10 +130,11 @@ begin
PageControl.ActivePage := TabSheetList; PageControl.ActivePage := TabSheetList;
if Assigned(IDEComponentPalette) then if Assigned(IDEComponentPalette) then
begin begin
UpdateComponentSelection; UpdateComponents;
with ListTree do with ListTree do
Selected := Items.GetFirstNode; Selected := Items.GetFirstNode;
TreeFilterEd.InvalidateFilter; TreeFilterEd.InvalidateFilter;
IDEComponentPalette.AddHandlerSelectionChanged(@SelectionWasChanged);
IDEComponentPalette.AddHandlerComponentAdded(@ComponentWasAdded); IDEComponentPalette.AddHandlerComponentAdded(@ComponentWasAdded);
end; end;
end; end;
@ -165,7 +167,7 @@ end;
procedure TComponentListForm.FormActivate(Sender: TObject); procedure TComponentListForm.FormActivate(Sender: TObject);
begin begin
if Assigned(IDEComponentPalette) and (IDEComponentPalette.ChangeStamp<>PrevChangeStamp) then if Assigned(IDEComponentPalette) and (IDEComponentPalette.ChangeStamp<>PrevChangeStamp) then
UpdateComponentSelection; UpdateComponents;
end; end;
procedure TComponentListForm.ClearSelection; procedure TComponentListForm.ClearSelection;
@ -175,24 +177,46 @@ begin
InheritanceTree.Selected := Nil; InheritanceTree.Selected := Nil;
end; end;
procedure SelectTreeComp(aTree: TTreeView);
var
Node: TTreeNode;
begin
with IDEComponentPalette do
if Assigned(Selected) then
Node := aTree.Items.FindNodeWithText(Selected.ComponentClass.ClassName)
else
Node := Nil;
aTree.Selected := Node;
end;
procedure TComponentListForm.SelectionWasChanged;
begin
// ToDo: Select the component in active treeview.
if ListTree.IsVisible then
SelectTreeComp(ListTree)
else if PalletteTree.IsVisible then
SelectTreeComp(PalletteTree)
else if InheritanceTree.IsVisible then
SelectTreeComp(InheritanceTree)
end;
function GetSelectedTreeComp(aTree: TTreeView): TRegisteredComponent;
begin
if Assigned(aTree.Selected) then
Result := TRegisteredComponent(aTree.Selected.Data)
else
Result := nil;
end;
function TComponentListForm.GetSelectedComponent: TRegisteredComponent; function TComponentListForm.GetSelectedComponent: TRegisteredComponent;
begin begin
Result:=nil; Result := nil;
if ListTree.IsVisible then if ListTree.IsVisible then
begin Result := GetSelectedTreeComp(ListTree)
if Assigned(ListTree.Selected) then
Result := TRegisteredComponent(ListTree.Selected.Data);
end
else if PalletteTree.IsVisible then else if PalletteTree.IsVisible then
begin Result := GetSelectedTreeComp(PalletteTree)
if Assigned(PalletteTree.Selected) then
Result := TRegisteredComponent(PalletteTree.Selected.Data);
end
else if InheritanceTree.IsVisible then else if InheritanceTree.IsVisible then
begin Result := GetSelectedTreeComp(InheritanceTree)
if Assigned(InheritanceTree.Selected) then
Result := TRegisteredComponent(InheritanceTree.Selected.Data);
end;
end; end;
procedure TComponentListForm.ComponentWasAdded; procedure TComponentListForm.ComponentWasAdded;
@ -268,7 +292,7 @@ begin
end; end;
end; end;
procedure TComponentListForm.UpdateComponentSelection; procedure TComponentListForm.UpdateComponents;
// Fill all three tabsheets: Flat list, Palette layout and Component inheritence. // Fill all three tabsheets: Flat list, Palette layout and Component inheritence.
var var
Pg: TBaseComponentPage; Pg: TBaseComponentPage;