mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 11:16:07 +02:00
MG: added expanding to unit dependencies
git-svn-id: trunk@3341 -
This commit is contained in:
parent
44e3418b75
commit
1d4aa7e976
@ -311,7 +311,8 @@ begin
|
|||||||
if Result=nil then exit;
|
if Result=nil then exit;
|
||||||
end;
|
end;
|
||||||
Result:=Result.FirstChild;
|
Result:=Result.FirstChild;
|
||||||
if (Result<>nil) and (Result.Desc<>ctnUsesSection) then Result:=nil;
|
if (Result=nil) then exit;
|
||||||
|
if (Result.Desc<>ctnUsesSection) then Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TStandardCodeTool.FindImplementationUsesSection: TCodeTreeNode;
|
function TStandardCodeTool.FindImplementationUsesSection: TCodeTreeNode;
|
||||||
@ -322,7 +323,8 @@ begin
|
|||||||
Result:=Result.NextBrother;
|
Result:=Result.NextBrother;
|
||||||
if Result=nil then exit;
|
if Result=nil then exit;
|
||||||
Result:=Result.FirstChild;
|
Result:=Result.FirstChild;
|
||||||
if (Result=nil) or (Result.Desc<>ctnUsesSection) then exit;
|
if (Result=nil) then exit;
|
||||||
|
if (Result.Desc<>ctnUsesSection) then Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TStandardCodeTool.RenameUsedUnit(const OldUpperUnitName,
|
function TStandardCodeTool.RenameUsedUnit(const OldUpperUnitName,
|
||||||
@ -535,9 +537,10 @@ begin
|
|||||||
try
|
try
|
||||||
MainUsesSection:=UsesSectionToFilenames(MainUsesNode);
|
MainUsesSection:=UsesSectionToFilenames(MainUsesNode);
|
||||||
ImplementationUsesSection:=UsesSectionToFilenames(ImplementatioUsesNode);
|
ImplementationUsesSection:=UsesSectionToFilenames(ImplementatioUsesNode);
|
||||||
finally
|
except
|
||||||
FreeAndNil(MainUsesSection);
|
FreeAndNil(MainUsesSection);
|
||||||
FreeAndNil(ImplementationUsesSection);
|
FreeAndNil(ImplementationUsesSection);
|
||||||
|
raise;
|
||||||
end;
|
end;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
@ -559,8 +562,9 @@ var
|
|||||||
NewCode: TCodeBuffer;
|
NewCode: TCodeBuffer;
|
||||||
UnitFilename: string;
|
UnitFilename: string;
|
||||||
begin
|
begin
|
||||||
MoveCursorToUsesEnd(UsesNode);
|
|
||||||
Result:=TStringList.Create;
|
Result:=TStringList.Create;
|
||||||
|
if UsesNode=nil then exit;
|
||||||
|
MoveCursorToUsesEnd(UsesNode);
|
||||||
repeat
|
repeat
|
||||||
// read prior unit name
|
// read prior unit name
|
||||||
ReadPriorUsedUnit(UnitNameAtom, InAtom);
|
ReadPriorUsedUnit(UnitNameAtom, InAtom);
|
||||||
|
@ -44,38 +44,85 @@ uses
|
|||||||
MemCheck,
|
MemCheck,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, Forms, Dialogs, Buttons, ComCtrls, StdCtrls,
|
Classes, SysUtils, Forms, Dialogs, Buttons, ComCtrls, StdCtrls,
|
||||||
CodeToolManager, EnvironmentOpts, LResources, IDEOptionDefs,
|
CodeToolManager, CodeCache, EnvironmentOpts, LResources, IDEOptionDefs,
|
||||||
LazarusIDEStrConsts, InputHistory;
|
LazarusIDEStrConsts, InputHistory;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
{ TUnitNode }
|
{ TUnitNode }
|
||||||
|
|
||||||
|
TUnitNodeFlag = (
|
||||||
|
unfImplementation,// this unit was used in an implementation uses section
|
||||||
|
unfCircle, // this unit is the parent of itself
|
||||||
|
unfFileNotFound, // this unit file was not found
|
||||||
|
unfParseError // error parsing the source
|
||||||
|
);
|
||||||
|
TUnitNodeFlags = set of TUnitNodeFlag;
|
||||||
|
|
||||||
|
TUnitNodeSourceType = (
|
||||||
|
unstUnknown,
|
||||||
|
unstUnit,
|
||||||
|
unstProgram,
|
||||||
|
unstLibrary,
|
||||||
|
unstPackage
|
||||||
|
);
|
||||||
|
|
||||||
|
const
|
||||||
|
UnitNodeSourceTypeNames: array[TUnitNodeSourceType] of string = (
|
||||||
|
'?',
|
||||||
|
'Unit',
|
||||||
|
'Program',
|
||||||
|
'Library',
|
||||||
|
'Package'
|
||||||
|
);
|
||||||
|
|
||||||
|
type
|
||||||
TUnitNode = class
|
TUnitNode = class
|
||||||
private
|
private
|
||||||
|
FChildCount: integer;
|
||||||
|
FCodeBuffer: TCodeBuffer;
|
||||||
FFilename: string;
|
FFilename: string;
|
||||||
FFirstChild: TUnitNode;
|
FFirstChild: TUnitNode;
|
||||||
|
FFlags: TUnitNodeFlags;
|
||||||
FLastChild: TUnitNode;
|
FLastChild: TUnitNode;
|
||||||
FNextSibling: TUnitNode;
|
FNextSibling: TUnitNode;
|
||||||
FParent: TUnitNode;
|
FParent: TUnitNode;
|
||||||
FPrevSibling: TUnitNode;
|
FPrevSibling: TUnitNode;
|
||||||
FShortFilename: string;
|
FShortFilename: string;
|
||||||
|
FSourceType: TUnitNodeSourceType;
|
||||||
FTreeNode: TTreeNode;
|
FTreeNode: TTreeNode;
|
||||||
|
procedure SetCodeBuffer(const AValue: TCodeBuffer);
|
||||||
procedure SetFilename(const AValue: string);
|
procedure SetFilename(const AValue: string);
|
||||||
|
procedure SetParent(const AValue: TUnitNode);
|
||||||
procedure SetShortFilename(const AValue: string);
|
procedure SetShortFilename(const AValue: string);
|
||||||
procedure SetTreeNode(const AValue: TTreeNode);
|
procedure SetTreeNode(const AValue: TTreeNode);
|
||||||
procedure CreateShortFilename;
|
procedure CreateShortFilename;
|
||||||
|
procedure UnbindFromParent;
|
||||||
|
procedure AddToParent;
|
||||||
|
procedure AddChild(const AFilename: string; ACodeBuffer: TCodeBuffer;
|
||||||
|
InImplementation: boolean);
|
||||||
|
procedure UpdateSourceType;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure ClearChilds;
|
||||||
procedure CreateChilds;
|
procedure CreateChilds;
|
||||||
|
procedure ClearGrandChildren;
|
||||||
|
procedure CreateGrandChildren;
|
||||||
|
function FindParentWithCodeBuffer(ACodeBuffer: TCodeBuffer): TUnitNode;
|
||||||
|
function HasChildren: boolean;
|
||||||
|
function IsImplementationNode: boolean;
|
||||||
|
property ChildCount: integer read FChildCount;
|
||||||
|
property CodeBuffer: TCodeBuffer read FCodeBuffer write SetCodeBuffer;
|
||||||
property Filename: string read FFilename write SetFilename;
|
property Filename: string read FFilename write SetFilename;
|
||||||
property FirstChild: TUnitNode read FFirstChild;
|
property FirstChild: TUnitNode read FFirstChild;
|
||||||
|
property Flags: TUnitNodeFlags read FFlags;
|
||||||
property LastChild: TUnitNode read FLastChild;
|
property LastChild: TUnitNode read FLastChild;
|
||||||
property NextSibling: TUnitNode read FNextSibling;
|
property NextSibling: TUnitNode read FNextSibling;
|
||||||
property PrevSibling: TUnitNode read FPrevSibling;
|
property PrevSibling: TUnitNode read FPrevSibling;
|
||||||
property Parent: TUnitNode read FParent;
|
property Parent: TUnitNode read FParent write SetParent;
|
||||||
property ShortFilename: string read FShortFilename write SetShortFilename;
|
property ShortFilename: string read FShortFilename write SetShortFilename;
|
||||||
|
property SourceType: TUnitNodeSourceType read FSourceType;
|
||||||
property TreeNode: TTreeNode read FTreeNode write SetTreeNode;
|
property TreeNode: TTreeNode read FTreeNode write SetTreeNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -88,11 +135,16 @@ type
|
|||||||
UnitTreeView: TTreeView;
|
UnitTreeView: TTreeView;
|
||||||
RefreshButton: TBitBtn;
|
RefreshButton: TBitBtn;
|
||||||
procedure UnitDependenciesViewResize(Sender: TObject);
|
procedure UnitDependenciesViewResize(Sender: TObject);
|
||||||
|
procedure UnitTreeViewCollapsing(Sender: TObject; Node: TTreeNode;
|
||||||
|
var AllowCollapse: Boolean);
|
||||||
|
procedure UnitTreeViewExpanding(Sender: TObject; Node: TTreeNode;
|
||||||
|
var AllowExpansion: Boolean);
|
||||||
private
|
private
|
||||||
|
FRootCodeBuffer: TCodeBuffer;
|
||||||
FRootFilename: string;
|
FRootFilename: string;
|
||||||
|
FRootNode: TUnitNode;
|
||||||
FRootShortFilename: string;
|
FRootShortFilename: string;
|
||||||
FRootValid: boolean;
|
FRootValid: boolean;
|
||||||
FRootNode: TUnitNode;
|
|
||||||
procedure DoResize;
|
procedure DoResize;
|
||||||
procedure ClearTree;
|
procedure ClearTree;
|
||||||
procedure RebuildTree;
|
procedure RebuildTree;
|
||||||
@ -119,6 +171,30 @@ begin
|
|||||||
DoResize;
|
DoResize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TUnitDependenciesView.UnitTreeViewCollapsing(Sender: TObject;
|
||||||
|
Node: TTreeNode; var AllowCollapse: Boolean);
|
||||||
|
var
|
||||||
|
UnitNode: TUnitNode;
|
||||||
|
begin
|
||||||
|
AllowCollapse:=true;
|
||||||
|
UnitNode:=TUnitNode(Node.Data);
|
||||||
|
UnitNode.ClearGrandChildren;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitDependenciesView.UnitTreeViewExpanding(Sender: TObject;
|
||||||
|
Node: TTreeNode; var AllowExpansion: Boolean);
|
||||||
|
var
|
||||||
|
UnitNode: TUnitNode;
|
||||||
|
begin
|
||||||
|
UnitNode:=TUnitNode(Node.Data);
|
||||||
|
if UnitNode.HasChildren then begin
|
||||||
|
AllowExpansion:=true;
|
||||||
|
UnitNode.CreateGrandChildren;
|
||||||
|
end else begin
|
||||||
|
AllowExpansion:=false;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUnitDependenciesView.DoResize;
|
procedure TUnitDependenciesView.DoResize;
|
||||||
begin
|
begin
|
||||||
with UnitHistoryList do begin
|
with UnitHistoryList do begin
|
||||||
@ -151,6 +227,7 @@ begin
|
|||||||
ClearTree;
|
ClearTree;
|
||||||
if RootFilename='' then exit;
|
if RootFilename='' then exit;
|
||||||
FRootNode:=TUnitNode.Create;
|
FRootNode:=TUnitNode.Create;
|
||||||
|
FRootNode.CodeBuffer:=FRootCodeBuffer;
|
||||||
FRootNode.Filename:=RootFilename;
|
FRootNode.Filename:=RootFilename;
|
||||||
FRootNode.ShortFilename:=FRootShortFilename;
|
FRootNode.ShortFilename:=FRootShortFilename;
|
||||||
UnitTreeView.Items.Clear;
|
UnitTreeView.Items.Clear;
|
||||||
@ -162,6 +239,7 @@ procedure TUnitDependenciesView.SetRootFilename(const AValue: string);
|
|||||||
begin
|
begin
|
||||||
if FRootFilename=AValue then exit;
|
if FRootFilename=AValue then exit;
|
||||||
FRootFilename:=AValue;
|
FRootFilename:=AValue;
|
||||||
|
FRootCodeBuffer:=CodeToolBoss.FindFile(FRootFilename);
|
||||||
FRootShortFilename:=FRootFilename;
|
FRootShortFilename:=FRootFilename;
|
||||||
RebuildTree;
|
RebuildTree;
|
||||||
UpdateUnitTree;
|
UpdateUnitTree;
|
||||||
@ -238,6 +316,8 @@ begin
|
|||||||
Top:=SelectUnitButton.Top+SelectUnitButton.Height+2;
|
Top:=SelectUnitButton.Top+SelectUnitButton.Height+2;
|
||||||
Width:=Parent.ClientWidth;
|
Width:=Parent.ClientWidth;
|
||||||
Height:=Parent.ClientHeight-Top;
|
Height:=Parent.ClientHeight-Top;
|
||||||
|
OnExpanding:=@UnitTreeViewExpanding;
|
||||||
|
OnCollapsing:=@UnitTreeViewCollapsing;
|
||||||
Visible:=true;
|
Visible:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -253,13 +333,30 @@ end;
|
|||||||
|
|
||||||
{ TUnitNode }
|
{ TUnitNode }
|
||||||
|
|
||||||
|
procedure TUnitNode.SetCodeBuffer(const AValue: TCodeBuffer);
|
||||||
|
begin
|
||||||
|
if CodeBuffer=AValue then exit;
|
||||||
|
FCodeBuffer:=AValue;
|
||||||
|
if CodeBuffer<>nil then
|
||||||
|
Filename:=CodeBuffer.Filename;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUnitNode.SetFilename(const AValue: string);
|
procedure TUnitNode.SetFilename(const AValue: string);
|
||||||
begin
|
begin
|
||||||
if FFilename=AValue then exit;
|
if Filename=AValue then exit;
|
||||||
FFilename:=AValue;
|
FFilename:=AValue;
|
||||||
|
FSourceType:=unstUnknown;
|
||||||
CreateShortFilename;
|
CreateShortFilename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.SetParent(const AValue: TUnitNode);
|
||||||
|
begin
|
||||||
|
if Parent=AValue then exit;
|
||||||
|
UnbindFromParent;
|
||||||
|
FParent:=AValue;
|
||||||
|
if Parent<>nil then AddToParent;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TUnitNode.SetShortFilename(const AValue: string);
|
procedure TUnitNode.SetShortFilename(const AValue: string);
|
||||||
begin
|
begin
|
||||||
if ShortFilename=AValue then exit;
|
if ShortFilename=AValue then exit;
|
||||||
@ -270,11 +367,12 @@ end;
|
|||||||
|
|
||||||
procedure TUnitNode.SetTreeNode(const AValue: TTreeNode);
|
procedure TUnitNode.SetTreeNode(const AValue: TTreeNode);
|
||||||
begin
|
begin
|
||||||
if FTreeNode=AValue then exit;
|
if TreeNode=AValue then exit;
|
||||||
FTreeNode:=AValue;
|
FTreeNode:=AValue;
|
||||||
if FTreeNode<>nil then begin
|
if TreeNode<>nil then begin
|
||||||
FTreeNode.Text:=ShortFilename;
|
TreeNode.Text:=ShortFilename;
|
||||||
|
TreeNode.Data:=Self;
|
||||||
|
TreeNode.HasChildren:=HasChildren;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -283,21 +381,160 @@ begin
|
|||||||
ShortFilename:=Filename;
|
ShortFilename:=Filename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.UnbindFromParent;
|
||||||
|
begin
|
||||||
|
if TreeNode<>nil then begin
|
||||||
|
TreeNode.Free;
|
||||||
|
TreeNode:=nil;
|
||||||
|
end;
|
||||||
|
if Parent<>nil then begin
|
||||||
|
if Parent.FirstChild=Self then Parent.FFirstChild:=NextSibling;
|
||||||
|
if Parent.LastChild=Self then Parent.FLastChild:=PrevSibling;
|
||||||
|
Dec(Parent.FChildCount);
|
||||||
|
end;
|
||||||
|
if NextSibling<>nil then NextSibling.FPrevSibling:=PrevSibling;
|
||||||
|
if PrevSibling<>nil then PrevSibling.FNextSibling:=NextSibling;
|
||||||
|
FNextSibling:=nil;
|
||||||
|
FPrevSibling:=nil;
|
||||||
|
FParent:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.AddToParent;
|
||||||
|
begin
|
||||||
|
if Parent=nil then exit;
|
||||||
|
|
||||||
|
FPrevSibling:=Parent.LastChild;
|
||||||
|
FNextSibling:=nil;
|
||||||
|
Parent.FLastChild:=Self;
|
||||||
|
if Parent.FirstChild=nil then Parent.FFirstChild:=Self;
|
||||||
|
if PrevSibling<>nil then PrevSibling.FNextSibling:=Self;
|
||||||
|
Inc(Parent.FChildCount);
|
||||||
|
|
||||||
|
if Parent.TreeNode<>nil then begin
|
||||||
|
Parent.TreeNode.HasChildren:=true;
|
||||||
|
TreeNode:=Parent.TreeNode.TreeNodes.AddChild(Parent.TreeNode,'');
|
||||||
|
if Parent.TreeNode.Expanded then begin
|
||||||
|
CreateChilds;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.AddChild(const AFilename: string; ACodeBuffer: TCodeBuffer;
|
||||||
|
InImplementation: boolean);
|
||||||
|
var
|
||||||
|
NewNode: TUnitNode;
|
||||||
|
begin
|
||||||
|
NewNode:=TUnitNode.Create;
|
||||||
|
NewNode.CodeBuffer:=ACodeBuffer;
|
||||||
|
NewNode.Filename:=AFilename;
|
||||||
|
if ACodeBuffer<>nil then begin
|
||||||
|
if FindParentWithCodeBuffer(ACodeBuffer)<>nil then
|
||||||
|
Include(NewNode.FFlags,unfCircle);
|
||||||
|
end else begin
|
||||||
|
Include(NewNode.FFlags,unfFileNotFound);
|
||||||
|
end;
|
||||||
|
if InImplementation then
|
||||||
|
Include(NewNode.FFlags,unfImplementation);
|
||||||
|
NewNode.Parent:=Self;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.UpdateSourceType;
|
||||||
|
var
|
||||||
|
SourceKeyWord: string;
|
||||||
|
begin
|
||||||
|
FSourceType:=unstUnknown;
|
||||||
|
if CodeBuffer=nil then exit;
|
||||||
|
SourceKeyWord:=CodeToolBoss.GetSourceType(CodeBuffer,false);
|
||||||
|
for FSourceType:=Low(TUnitNodeSourceType) to High(TUnitNodeSourceType) do
|
||||||
|
if AnsiCompareText(SourceKeyWord,UnitNodeSourceTypeNames[FSourceType])=0
|
||||||
|
then
|
||||||
|
exit;
|
||||||
|
FSourceType:=unstUnknown;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TUnitNode.Create;
|
constructor TUnitNode.Create;
|
||||||
begin
|
begin
|
||||||
|
inherited Create;
|
||||||
|
FSourceType:=unstUnknown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TUnitNode.Destroy;
|
destructor TUnitNode.Destroy;
|
||||||
begin
|
begin
|
||||||
|
ClearChilds;
|
||||||
|
Parent:=nil;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TUnitNode.CreateChilds;
|
procedure TUnitNode.ClearChilds;
|
||||||
//var
|
|
||||||
// UsedInterfaceFilenames, UsedImplementation: TStrings;
|
|
||||||
begin
|
begin
|
||||||
//CodeToolBoss.FindUsedUnits();
|
while LastChild<>nil do
|
||||||
|
LastChild.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.CreateChilds;
|
||||||
|
var
|
||||||
|
UsedInterfaceFilenames, UsedImplementationFilenames: TStrings;
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
ClearChilds;
|
||||||
|
UpdateSourceType;
|
||||||
|
if CodeBuffer=nil then exit;
|
||||||
|
if CodeToolBoss.FindUsedUnits(CodeBuffer,
|
||||||
|
UsedInterfaceFilenames,
|
||||||
|
UsedImplementationFilenames) then
|
||||||
|
begin
|
||||||
|
Exclude(FFlags,unfParseError);
|
||||||
|
for i:=0 to UsedInterfaceFilenames.Count-1 do
|
||||||
|
AddChild(UsedInterfaceFilenames[i],
|
||||||
|
TCodeBuffer(UsedInterfaceFilenames.Objects[i]),false);
|
||||||
|
UsedInterfaceFilenames.Free;
|
||||||
|
for i:=0 to UsedImplementationFilenames.Count-1 do
|
||||||
|
AddChild(UsedImplementationFilenames[i],
|
||||||
|
TCodeBuffer(UsedImplementationFilenames.Objects[i]),true);
|
||||||
|
UsedImplementationFilenames.Free;
|
||||||
|
end else begin
|
||||||
|
Include(FFlags,unfParseError);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.ClearGrandChildren;
|
||||||
|
var
|
||||||
|
AChildNode: TUnitNode;
|
||||||
|
begin
|
||||||
|
AChildNode:=FirstChild;
|
||||||
|
while AChildNode<>nil do begin
|
||||||
|
AChildNode.ClearChilds;
|
||||||
|
AChildNode:=AChildNode.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TUnitNode.CreateGrandChildren;
|
||||||
|
var
|
||||||
|
AChildNode: TUnitNode;
|
||||||
|
begin
|
||||||
|
AChildNode:=FirstChild;
|
||||||
|
while AChildNode<>nil do begin
|
||||||
|
AChildNode.CreateChilds;
|
||||||
|
AChildNode:=AChildNode.NextSibling;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TUnitNode.FindParentWithCodeBuffer(ACodeBuffer: TCodeBuffer
|
||||||
|
): TUnitNode;
|
||||||
|
begin
|
||||||
|
Result:=Parent;
|
||||||
|
while (Result<>nil) and (Result.CodeBuffer<>ACodeBuffer) do
|
||||||
|
Result:=Result.Parent;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TUnitNode.HasChildren: boolean;
|
||||||
|
begin
|
||||||
|
Result:=FChildCount>0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TUnitNode.IsImplementationNode: boolean;
|
||||||
|
begin
|
||||||
|
Result:=unfImplementation in FFlags;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -1396,8 +1396,8 @@ type
|
|||||||
property OnDeletion: TTVExpandedEvent read FOnDeletion write FOnDeletion;
|
property OnDeletion: TTVExpandedEvent read FOnDeletion write FOnDeletion;
|
||||||
property OnEditing: TTVEditingEvent read FOnEditing write FOnEditing;
|
property OnEditing: TTVEditingEvent read FOnEditing write FOnEditing;
|
||||||
property OnEdited: TTVEditedEvent read FOnEdited write FOnEdited;
|
property OnEdited: TTVEditedEvent read FOnEdited write FOnEdited;
|
||||||
property OnExpanding: TTVExpandingEvent read FOnExpanding write FOnExpanding;
|
|
||||||
property OnExpanded: TTVExpandedEvent read FOnExpanded write FOnExpanded;
|
property OnExpanded: TTVExpandedEvent read FOnExpanded write FOnExpanded;
|
||||||
|
property OnExpanding: TTVExpandingEvent read FOnExpanding write FOnExpanding;
|
||||||
property OnGetImageIndex: TTVExpandedEvent
|
property OnGetImageIndex: TTVExpandedEvent
|
||||||
read FOnGetImageIndex write FOnGetImageIndex;
|
read FOnGetImageIndex write FOnGetImageIndex;
|
||||||
property OnGetSelectedIndex: TTVExpandedEvent
|
property OnGetSelectedIndex: TTVExpandedEvent
|
||||||
@ -1521,8 +1521,8 @@ type
|
|||||||
property OnEndDrag;
|
property OnEndDrag;
|
||||||
property OnEnter;
|
property OnEnter;
|
||||||
property OnExit;
|
property OnExit;
|
||||||
property OnExpanding;
|
|
||||||
property OnExpanded;
|
property OnExpanded;
|
||||||
|
property OnExpanding;
|
||||||
property OnGetImageIndex;
|
property OnGetImageIndex;
|
||||||
property OnGetSelectedIndex;
|
property OnGetSelectedIndex;
|
||||||
property OnKeyDown;
|
property OnKeyDown;
|
||||||
@ -1600,6 +1600,9 @@ end.
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.47 2002/09/14 10:39:40 lazarus
|
||||||
|
MG: added expanding to unit dependencies
|
||||||
|
|
||||||
Revision 1.46 2002/09/14 08:38:05 lazarus
|
Revision 1.46 2002/09/14 08:38:05 lazarus
|
||||||
MG: added TListView notification from Vincent
|
MG: added TListView notification from Vincent
|
||||||
|
|
||||||
|
@ -107,9 +107,9 @@ destructor TTreeNode.Destroy;
|
|||||||
// Node: TTreeNode;
|
// Node: TTreeNode;
|
||||||
// CheckValue: Integer;
|
// CheckValue: Integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF TREEVIEW_DEBUG}
|
{$IFDEF TREEVIEW_DEBUG}
|
||||||
writeln('[TTreeNode.Destroy] Self=',HexStr(Cardinal(Self),8),' Self.Text=',Text);
|
writeln('[TTreeNode.Destroy] Self=',HexStr(Cardinal(Self),8),' Self.Text=',Text);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FDeleting := True;
|
FDeleting := True;
|
||||||
HasChildren := false;
|
HasChildren := false;
|
||||||
Unbind;
|
Unbind;
|
||||||
@ -368,8 +368,10 @@ function TTreeNode.DoCanExpand(ExpandIt: Boolean): Boolean;
|
|||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if (TreeView<>nil) and HasChildren then begin
|
if (TreeView<>nil) and HasChildren then begin
|
||||||
if ExpandIt then Result := TreeView.CanExpand(Self)
|
if ExpandIt then
|
||||||
else Result := TreeView.CanCollapse(Self);
|
Result := TreeView.CanExpand(Self)
|
||||||
|
else
|
||||||
|
Result := TreeView.CanCollapse(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -584,8 +586,8 @@ procedure TTreeNode.SetHasChildren(AValue: Boolean);
|
|||||||
//var Item: TTVItem;
|
//var Item: TTVItem;
|
||||||
begin
|
begin
|
||||||
if AValue=HasChildren then exit;
|
if AValue=HasChildren then exit;
|
||||||
//writeln('[TTreeNode.SetHasChildren] Self=',HexStr(Cardinal(Self),8),
|
//writeln('[TTreeNode.SetHasChildren] Self=',HexStr(Cardinal(Self),8),
|
||||||
//' Self.Text=',Text,' AValue=',AValue);
|
//' Self.Text=',Text,' AValue=',AValue);
|
||||||
if AValue then
|
if AValue then
|
||||||
Include(FStates,nsHasChildren)
|
Include(FStates,nsHasChildren)
|
||||||
else begin
|
else begin
|
||||||
@ -1024,7 +1026,7 @@ begin
|
|||||||
taInsert:
|
taInsert:
|
||||||
begin
|
begin
|
||||||
// insert node in front of ANode
|
// insert node in front of ANode
|
||||||
//writeln('[TTreeNode.InternalMove] ANode.Index=',ANode.Index,' ANode=',HexStr(Cardinal(ANode),8));
|
//writeln('[TTreeNode.InternalMove] ANode.Index=',ANode.Index,' ANode=',HexStr(Cardinal(ANode),8));
|
||||||
FNextBrother:=ANode;
|
FNextBrother:=ANode;
|
||||||
FPrevBrother:=ANode.GetPrevSibling;
|
FPrevBrother:=ANode.GetPrevSibling;
|
||||||
if Owner<>nil then begin
|
if Owner<>nil then begin
|
||||||
@ -1040,12 +1042,12 @@ begin
|
|||||||
Owner.Owner.FStates:=Owner.Owner.FStates+[tvsMaxRightNeedsUpdate,
|
Owner.Owner.FStates:=Owner.Owner.FStates+[tvsMaxRightNeedsUpdate,
|
||||||
tvsTopsNeedsUpdate,tvsTopItemNeedsUpdate,tvsBottomItemNeedsUpdate];
|
tvsTopsNeedsUpdate,tvsTopItemNeedsUpdate,tvsBottomItemNeedsUpdate];
|
||||||
|
|
||||||
{$IFDEF TREEVIEW_DEBUG}
|
{$IFDEF TREEVIEW_DEBUG}
|
||||||
write('[TTreeNode.InternalMove] END Self=',HexStr(Cardinal(Self),8),' Self.Text=',Text
|
write('[TTreeNode.InternalMove] END Self=',HexStr(Cardinal(Self),8),' Self.Text=',Text
|
||||||
,' ANode=',ANode<>nil,' AddMode=',AddModeNames[AddMode]);
|
,' ANode=',ANode<>nil,' AddMode=',AddModeNames[AddMode]);
|
||||||
if ANode<>nil then write(' ANode.Text=',ANode.Text);
|
if ANode<>nil then write(' ANode.Text=',ANode.Text);
|
||||||
writeln('');
|
writeln('');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
{var
|
{var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
@ -1815,7 +1817,10 @@ begin
|
|||||||
Result:=GetLastNode;
|
Result:=GetLastNode;
|
||||||
while (Result<>nil) and (Result.Expanded) do begin
|
while (Result<>nil) and (Result.Expanded) do begin
|
||||||
Node:=Result.GetLastChild;
|
Node:=Result.GetLastChild;
|
||||||
if Node<>nil then Result:=Node;
|
if Node<>nil then
|
||||||
|
Result:=Node
|
||||||
|
else
|
||||||
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1956,10 +1961,10 @@ procedure TTreeNodes.MoveTopLvlNode(TopLvlFromIndex, TopLvlToIndex: integer;
|
|||||||
Node: TTreeNode);
|
Node: TTreeNode);
|
||||||
var i: integer;
|
var i: integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF TREEVIEW_DEBUG}
|
{$IFDEF TREEVIEW_DEBUG}
|
||||||
writeln('[TTreeNodes.MoveTopLvlNode] TopLvlFromIndex=',TopLvlFromIndex,
|
writeln('[TTreeNodes.MoveTopLvlNode] TopLvlFromIndex=',TopLvlFromIndex,
|
||||||
' TopLvlToIndex=',TopLvlToIndex,' Node.Text=',Node.Text);
|
' TopLvlToIndex=',TopLvlToIndex,' Node.Text=',Node.Text);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if (TopLvlFromIndex>=FTopLvlCount) then
|
if (TopLvlFromIndex>=FTopLvlCount) then
|
||||||
TreeNodeError('TTreeNodes.MoveTopLvlNode TopLvlFromIndex>FTopLvlCount');
|
TreeNodeError('TTreeNodes.MoveTopLvlNode TopLvlFromIndex>FTopLvlCount');
|
||||||
if (TopLvlToIndex>FTopLvlCount) then
|
if (TopLvlToIndex>FTopLvlCount) then
|
||||||
@ -2155,10 +2160,10 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
inc(RealCount,Node.SubTreeCount);
|
inc(RealCount,Node.SubTreeCount);
|
||||||
//writeln(' ConsistencyCheck: B ',RealCount,',',Node.SubTreeCount);
|
//writeln(' ConsistencyCheck: B ',RealCount,',',Node.SubTreeCount);
|
||||||
Node:=Node.FNextBrother;
|
Node:=Node.FNextBrother;
|
||||||
end;
|
end;
|
||||||
//writeln(' ConsistencyCheck: B ',RealCount,',',FCount);
|
//writeln(' ConsistencyCheck: B ',RealCount,',',FCount);
|
||||||
if RealCount<>FCount then exit(-3);
|
if RealCount<>FCount then exit(-3);
|
||||||
if (FTopLvlCapacity<=0) and (FTopLvlItems<>nil) then exit(-4);
|
if (FTopLvlCapacity<=0) and (FTopLvlItems<>nil) then exit(-4);
|
||||||
if (FTopLvlCapacity>0) and (FTopLvlItems=nil) then exit(-5);
|
if (FTopLvlCapacity>0) and (FTopLvlItems=nil) then exit(-5);
|
||||||
@ -2170,7 +2175,7 @@ begin
|
|||||||
exit(-9);
|
exit(-9);
|
||||||
if (i<FTopLvlCount-1) and (FTopLvlItems[i].FNextBrother<>FTopLvlItems[i+1])
|
if (i<FTopLvlCount-1) and (FTopLvlItems[i].FNextBrother<>FTopLvlItems[i+1])
|
||||||
then begin
|
then begin
|
||||||
writeln(' CONSISTENCY i=',i,' FTopLvlCount=',FTopLvlCount,' FTopLvlItems[i]=',HexStr(Cardinal(FTopLvlItems[i]),8),' FTopLvlItems[i].FNextBrother=',HexStr(Cardinal(FTopLvlItems[i].FNextBrother),8),' FTopLvlItems[i+1]=',HexStr(Cardinal(FTopLvlItems[i+1]),8));
|
writeln(' CONSISTENCY i=',i,' FTopLvlCount=',FTopLvlCount,' FTopLvlItems[i]=',HexStr(Cardinal(FTopLvlItems[i]),8),' FTopLvlItems[i].FNextBrother=',HexStr(Cardinal(FTopLvlItems[i].FNextBrother),8),' FTopLvlItems[i+1]=',HexStr(Cardinal(FTopLvlItems[i+1]),8));
|
||||||
exit(-10);
|
exit(-10);
|
||||||
end;
|
end;
|
||||||
if (i=FTopLvlCount-1) and (FTopLvlItems[i].FNextBrother<>nil) then
|
if (i=FTopLvlCount-1) and (FTopLvlItems[i].FNextBrother<>nil) then
|
||||||
@ -3179,18 +3184,18 @@ end;
|
|||||||
function TCustomTreeView.IsNodeVisible(ANode: TTreeNode): Boolean;
|
function TCustomTreeView.IsNodeVisible(ANode: TTreeNode): Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=(ANode<>nil) and (ANode.AreParentsExpanded);
|
Result:=(ANode<>nil) and (ANode.AreParentsExpanded);
|
||||||
//writeln('[TCustomTreeView.IsNodeVisible] A Node=',HexStr(Cardinal(ANode),8),
|
//writeln('[TCustomTreeView.IsNodeVisible] A Node=',HexStr(Cardinal(ANode),8),
|
||||||
//' ANode.AreParentsExpanded=',ANode.AreParentsExpanded);
|
//' ANode.AreParentsExpanded=',ANode.AreParentsExpanded);
|
||||||
if Result then begin
|
if Result then begin
|
||||||
//writeln('[TCustomTreeView.IsNodeVisible] B Node=',HexStr(Cardinal(ANode),8),
|
//writeln('[TCustomTreeView.IsNodeVisible] B Node=',HexStr(Cardinal(ANode),8),
|
||||||
//' ',FScrolledTop,'>=',ANode.Top,'+',ANode.Height,' or ',FScrolledTop,'+',ClientHeight,'<',ANode.Top);
|
//' ',FScrolledTop,'>=',ANode.Top,'+',ANode.Height,' or ',FScrolledTop,'+',ClientHeight,'<',ANode.Top);
|
||||||
if (FScrolledTop>=ANode.Top+ANode.Height)
|
if (FScrolledTop>=ANode.Top+ANode.Height)
|
||||||
or (FScrolledTop+(ClientHeight-ScrollBarWidth)-2*BorderWidth<ANode.Top)
|
or (FScrolledTop+(ClientHeight-ScrollBarWidth)-2*BorderWidth<ANode.Top)
|
||||||
then
|
then
|
||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
//writeln('[TCustomTreeView.IsNodeVisible] END Node=',HexStr(Cardinal(ANode),8),
|
//writeln('[TCustomTreeView.IsNodeVisible] END Node=',HexStr(Cardinal(ANode),8),
|
||||||
//' Node.Text=',ANode.Text,' Visible=',Result);
|
//' Node.Text=',ANode.Text,' Visible=',Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomTreeView.Loaded;
|
procedure TCustomTreeView.Loaded;
|
||||||
@ -3751,7 +3756,7 @@ end;
|
|||||||
procedure TCustomTreeView.CMDrag(var AMessage: TCMDrag);
|
procedure TCustomTreeView.CMDrag(var AMessage: TCMDrag);
|
||||||
begin
|
begin
|
||||||
inherited CMDrag(AMessage);
|
inherited CMDrag(AMessage);
|
||||||
writeln('TCustomTreeView.CMDrag ',ord(AMessage.DragMessage));
|
writeln('TCustomTreeView.CMDrag ',ord(AMessage.DragMessage));
|
||||||
with AMessage, DragRec^ do
|
with AMessage, DragRec^ do
|
||||||
case DragMessage of
|
case DragMessage of
|
||||||
dmDragMove:
|
dmDragMove:
|
||||||
@ -3774,7 +3779,7 @@ var
|
|||||||
Node: TTreeNode;
|
Node: TTreeNode;
|
||||||
begin
|
begin
|
||||||
Node := GetNodeAt(X, Y);
|
Node := GetNodeAt(X, Y);
|
||||||
writeln('TCustomTreeView.DoDragOver ',Node<>nil,' ',Node <> DropTarget,' ',Node = FLastDropTarget);
|
writeln('TCustomTreeView.DoDragOver ',Node<>nil,' ',Node <> DropTarget,' ',Node = FLastDropTarget);
|
||||||
if (Node <> nil)
|
if (Node <> nil)
|
||||||
and ((Node <> DropTarget) or (Node = FLastDropTarget)) then
|
and ((Node <> DropTarget) or (Node = FLastDropTarget)) then
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user