fixed TApplication.GetTitle

git-svn-id: trunk@4512 -
This commit is contained in:
mattias 2003-08-22 13:51:25 +00:00
parent 94d074b813
commit 2ba9e24665
4 changed files with 60 additions and 8 deletions

View File

@ -40,11 +40,12 @@ type
FComponentList: TComponentSelectionList;
FPropertyEditorHook: TPropertyEditorHook;
procedure SetPropertyEditorHook(const AValue: TPropertyEditorHook);
procedure SetSelections(const AValue: TComponentSelectionList);
procedure SetSelections(const NewSelections: TComponentSelectionList);
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure RebuildComponentNodes; virtual;
function CreateNodeCaption(AComponent: TComponent): string; virtual;
public
property Selections: TComponentSelectionList read FComponentList
write SetSelections;
@ -56,11 +57,10 @@ implementation
{ TComponentTreeView }
procedure TComponentTreeView.SetSelections(const AValue: TComponentSelectionList
);
procedure TComponentTreeView.SetSelections(
const NewSelections: TComponentSelectionList);
begin
if FComponentList=AValue then exit;
FComponentList:=AValue;
FComponentList.Assign(NewSelections);
RebuildComponentNodes;
end;
@ -69,12 +69,14 @@ procedure TComponentTreeView.SetPropertyEditorHook(
begin
if FPropertyEditorHook=AValue then exit;
FPropertyEditorHook:=AValue;
RebuildComponentNodes;
end;
constructor TComponentTreeView.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FComponentList:=TComponentSelectionList.Create;
Options:=Options+[tvoAllowMultiselect,tvoAutoItemHeight,tvoKeepCollapsedNodes];
end;
destructor TComponentTreeView.Destroy;
@ -84,8 +86,46 @@ begin
end;
procedure TComponentTreeView.RebuildComponentNodes;
var
OldExpanded: TTreeNodeExpandedState;
NewNode: TTreeNode;
RootComponent: TComponent;
i: Integer;
AComponent: TComponent;
RootNode: TTreeNode;
begin
BeginUpdate;
// save old expanded state and clear
OldExpanded:=TTreeNodeExpandedState.Create(Self);
Items.Clear;
RootComponent:=PropertyEditorHook.LookupRoot;
if RootComponent<>nil then begin
// first add the lookup root
RootNode:=Items.Add(nil,CreateNodeCaption(RootComponent));
RootNode.ImageIndex:=-1;
RootNode.Selected:=Selections.IndexOf(RootComponent)>=0;
// add components in creation order
for i:=0 to RootComponent.ComponentCount-1 do begin
AComponent:=RootComponent.Components[i];
NewNode:=Items.AddChild(RootNode,CreateNodeCaption(AComponent));
NewNode.ImageIndex:=-1;
NewNode.Selected:=Selections.IndexOf(AComponent)>=0;
end;
RootNode.Expand(true);
end;
// restore old expanded state
OldExpanded.Apply(Self);
OldExpanded.Free;
EndUpdate;
end;
function TComponentTreeView.CreateNodeCaption(AComponent: TComponent): string;
begin
Result:=AComponent.Name+': '+AComponent.ClassName;
end;
end.

View File

@ -2287,6 +2287,7 @@ begin
FillComponentComboBox;
PropertyGrid.PropertyEditorHook:=FPropertyEditorHook;
EventGrid.PropertyEditorHook:=FPropertyEditorHook;
ComponentTree.PropertyEditorHook:=FPropertyEditorHook;
RefreshSelections;
end;
end;
@ -2420,6 +2421,7 @@ procedure TObjectInspector.RefreshSelections;
begin
PropertyGrid.Selections:=FComponentList;
EventGrid.Selections:=FComponentList;
ComponentTree.Selections:=FComponentList;
if (not Visible) and (FComponentList.Count>0) then
Visible:=true;
end;

View File

@ -868,9 +868,12 @@ type
function GetCapacity:integer;
procedure SetCapacity(const NewCapacity:integer);
public
constructor Create;
destructor Destroy; override;
procedure BeginUpdate;
procedure EndUpdate;
function UpdateLock: integer;
function IndexOf(AComponent: TComponent): integer;
procedure Clear;
function IsEqual(SourceSelectionList: TComponentSelectionList): boolean;
property Count:integer read GetCount;
@ -878,8 +881,6 @@ type
function Add(AComponent: TComponent): integer;
procedure Assign(SourceSelectionList: TComponentSelectionList);
property Items[Index: integer]: TComponent read GetItems write SetItems; default;
constructor Create;
destructor Destroy; override;
end;
//==============================================================================
@ -4179,6 +4180,12 @@ begin
Result:=FUpdateLock;
end;
function TComponentSelectionList.IndexOf(AComponent: TComponent): integer;
begin
Result:=Count-1;
while (Result>=0) and (Items[Result]<>AComponent) do dec(Result);
end;
procedure TComponentSelectionList.Assign(
SourceSelectionList:TComponentSelectionList);
var a:integer;

View File

@ -664,7 +664,7 @@ function TApplication.GetTitle: string;
var
Ext: string;
begin
Result := Title;
Result := inherited Title;
If Result = '' then begin
Result := ExtractFileName(GetExeName);
Ext := ExtractFileExt(Result);
@ -1131,6 +1131,9 @@ end;
{ =============================================================================
$Log$
Revision 1.62 2003/08/22 13:51:25 mattias
fixed TApplication.GetTitle
Revision 1.61 2003/08/12 21:35:11 mattias
TApplication now descends from TCustomApplication