mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 01:19:16 +02:00
fixed TApplication.GetTitle
git-svn-id: trunk@4512 -
This commit is contained in:
parent
94d074b813
commit
2ba9e24665
@ -40,11 +40,12 @@ type
|
|||||||
FComponentList: TComponentSelectionList;
|
FComponentList: TComponentSelectionList;
|
||||||
FPropertyEditorHook: TPropertyEditorHook;
|
FPropertyEditorHook: TPropertyEditorHook;
|
||||||
procedure SetPropertyEditorHook(const AValue: TPropertyEditorHook);
|
procedure SetPropertyEditorHook(const AValue: TPropertyEditorHook);
|
||||||
procedure SetSelections(const AValue: TComponentSelectionList);
|
procedure SetSelections(const NewSelections: TComponentSelectionList);
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure RebuildComponentNodes; virtual;
|
procedure RebuildComponentNodes; virtual;
|
||||||
|
function CreateNodeCaption(AComponent: TComponent): string; virtual;
|
||||||
public
|
public
|
||||||
property Selections: TComponentSelectionList read FComponentList
|
property Selections: TComponentSelectionList read FComponentList
|
||||||
write SetSelections;
|
write SetSelections;
|
||||||
@ -56,11 +57,10 @@ implementation
|
|||||||
|
|
||||||
{ TComponentTreeView }
|
{ TComponentTreeView }
|
||||||
|
|
||||||
procedure TComponentTreeView.SetSelections(const AValue: TComponentSelectionList
|
procedure TComponentTreeView.SetSelections(
|
||||||
);
|
const NewSelections: TComponentSelectionList);
|
||||||
begin
|
begin
|
||||||
if FComponentList=AValue then exit;
|
FComponentList.Assign(NewSelections);
|
||||||
FComponentList:=AValue;
|
|
||||||
RebuildComponentNodes;
|
RebuildComponentNodes;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -69,12 +69,14 @@ procedure TComponentTreeView.SetPropertyEditorHook(
|
|||||||
begin
|
begin
|
||||||
if FPropertyEditorHook=AValue then exit;
|
if FPropertyEditorHook=AValue then exit;
|
||||||
FPropertyEditorHook:=AValue;
|
FPropertyEditorHook:=AValue;
|
||||||
|
RebuildComponentNodes;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TComponentTreeView.Create(TheOwner: TComponent);
|
constructor TComponentTreeView.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
FComponentList:=TComponentSelectionList.Create;
|
FComponentList:=TComponentSelectionList.Create;
|
||||||
|
Options:=Options+[tvoAllowMultiselect,tvoAutoItemHeight,tvoKeepCollapsedNodes];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TComponentTreeView.Destroy;
|
destructor TComponentTreeView.Destroy;
|
||||||
@ -84,8 +86,46 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComponentTreeView.RebuildComponentNodes;
|
procedure TComponentTreeView.RebuildComponentNodes;
|
||||||
|
var
|
||||||
|
OldExpanded: TTreeNodeExpandedState;
|
||||||
|
NewNode: TTreeNode;
|
||||||
|
RootComponent: TComponent;
|
||||||
|
i: Integer;
|
||||||
|
AComponent: TComponent;
|
||||||
|
RootNode: TTreeNode;
|
||||||
begin
|
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;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -2287,6 +2287,7 @@ begin
|
|||||||
FillComponentComboBox;
|
FillComponentComboBox;
|
||||||
PropertyGrid.PropertyEditorHook:=FPropertyEditorHook;
|
PropertyGrid.PropertyEditorHook:=FPropertyEditorHook;
|
||||||
EventGrid.PropertyEditorHook:=FPropertyEditorHook;
|
EventGrid.PropertyEditorHook:=FPropertyEditorHook;
|
||||||
|
ComponentTree.PropertyEditorHook:=FPropertyEditorHook;
|
||||||
RefreshSelections;
|
RefreshSelections;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2420,6 +2421,7 @@ procedure TObjectInspector.RefreshSelections;
|
|||||||
begin
|
begin
|
||||||
PropertyGrid.Selections:=FComponentList;
|
PropertyGrid.Selections:=FComponentList;
|
||||||
EventGrid.Selections:=FComponentList;
|
EventGrid.Selections:=FComponentList;
|
||||||
|
ComponentTree.Selections:=FComponentList;
|
||||||
if (not Visible) and (FComponentList.Count>0) then
|
if (not Visible) and (FComponentList.Count>0) then
|
||||||
Visible:=true;
|
Visible:=true;
|
||||||
end;
|
end;
|
||||||
|
@ -868,9 +868,12 @@ type
|
|||||||
function GetCapacity:integer;
|
function GetCapacity:integer;
|
||||||
procedure SetCapacity(const NewCapacity:integer);
|
procedure SetCapacity(const NewCapacity:integer);
|
||||||
public
|
public
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
function UpdateLock: integer;
|
function UpdateLock: integer;
|
||||||
|
function IndexOf(AComponent: TComponent): integer;
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
function IsEqual(SourceSelectionList: TComponentSelectionList): boolean;
|
function IsEqual(SourceSelectionList: TComponentSelectionList): boolean;
|
||||||
property Count:integer read GetCount;
|
property Count:integer read GetCount;
|
||||||
@ -878,8 +881,6 @@ type
|
|||||||
function Add(AComponent: TComponent): integer;
|
function Add(AComponent: TComponent): integer;
|
||||||
procedure Assign(SourceSelectionList: TComponentSelectionList);
|
procedure Assign(SourceSelectionList: TComponentSelectionList);
|
||||||
property Items[Index: integer]: TComponent read GetItems write SetItems; default;
|
property Items[Index: integer]: TComponent read GetItems write SetItems; default;
|
||||||
constructor Create;
|
|
||||||
destructor Destroy; override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
@ -4179,6 +4180,12 @@ begin
|
|||||||
Result:=FUpdateLock;
|
Result:=FUpdateLock;
|
||||||
end;
|
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(
|
procedure TComponentSelectionList.Assign(
|
||||||
SourceSelectionList:TComponentSelectionList);
|
SourceSelectionList:TComponentSelectionList);
|
||||||
var a:integer;
|
var a:integer;
|
||||||
|
@ -664,7 +664,7 @@ function TApplication.GetTitle: string;
|
|||||||
var
|
var
|
||||||
Ext: string;
|
Ext: string;
|
||||||
begin
|
begin
|
||||||
Result := Title;
|
Result := inherited Title;
|
||||||
If Result = '' then begin
|
If Result = '' then begin
|
||||||
Result := ExtractFileName(GetExeName);
|
Result := ExtractFileName(GetExeName);
|
||||||
Ext := ExtractFileExt(Result);
|
Ext := ExtractFileExt(Result);
|
||||||
@ -1131,6 +1131,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.62 2003/08/22 13:51:25 mattias
|
||||||
|
fixed TApplication.GetTitle
|
||||||
|
|
||||||
Revision 1.61 2003/08/12 21:35:11 mattias
|
Revision 1.61 2003/08/12 21:35:11 mattias
|
||||||
TApplication now descends from TCustomApplication
|
TApplication now descends from TCustomApplication
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user