LCL: refactor TreeView, move GetNodeAtInternalY inside GetNodeAtY

git-svn-id: trunk@35284 -
This commit is contained in:
juha 2012-02-10 12:06:07 +00:00
parent 8cbd938dd7
commit 9283707671
2 changed files with 15 additions and 24 deletions

View File

@ -2840,7 +2840,6 @@ type
function GetMaxLvl: integer;
function GetMaxScrollLeft: integer;
function GetMaxScrollTop: integer;
function GetNodeAtInternalY(Y: Integer): TTreeNode;
function GetNodeAtY(Y: Integer): TTreeNode;
function GetNodeDrawAreaHeight: integer;
function GetNodeDrawAreaWidth: integer;

View File

@ -3621,36 +3621,28 @@ begin
end;
end;
function TCustomTreeView.GetNodeAtInternalY(Y: Integer): TTreeNode;
// search in all expanded nodes for the node at the absolute coordinate Y
var
i: integer;
begin
i := IndexOfNodeAtTop(Items.FTopLvlItems, Items.FTopLvlCount, Y);
if i >= 0 then
begin
Result := Items.FTopLvlItems[i];
while Result.Visible and Result.Expanded do
begin
i := IndexOfNodeAtTop(Result.FItems, Result.FCount, Y);
if i >= 0 then
Result := Result.Items[i]
else
break;
end;
end
else
Result := nil;
end;
function TCustomTreeView.GetNodeAtY(Y: Integer): TTreeNode;
// search in all expanded nodes for the node at the screen coordinate Y
var
i: integer;
begin
Result := nil;
if (Y >= BorderWidth) and (Y < (ClientHeight - ScrollBarWidth) - BorderWidth) then
begin
inc(Y, FScrolledTop - BorderWidth);
Result := GetNodeAtInternalY(Y);
i := IndexOfNodeAtTop(Items.FTopLvlItems, Items.FTopLvlCount, Y);
if i >= 0 then
begin
Result := Items.FTopLvlItems[i];
while Result.Visible and Result.Expanded do
begin
i := IndexOfNodeAtTop(Result.FItems, Result.FCount, Y);
if i >= 0 then
Result := Result.Items[i]
else
break;
end;
end;
end;
end;