mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 06:42:46 +02:00
LCL: Implemented TCustomListView.GetNextItem() and TCustomListView.GetNearestItem() for delphi compatibility. issue #23077
git-svn-id: trunk@38980 -
This commit is contained in:
parent
d9957bbeea
commit
22e8584d0a
@ -1457,6 +1457,21 @@ type
|
|||||||
function FindData(StartIndex: Integer; Value: Pointer; Inclusive, Wrap: Boolean): TListItem;
|
function FindData(StartIndex: Integer; Value: Pointer; Inclusive, Wrap: Boolean): TListItem;
|
||||||
function GetHitTestInfoAt(X, Y: Integer): THitTests;
|
function GetHitTestInfoAt(X, Y: Integer): THitTests;
|
||||||
function GetItemAt(x,y: integer): TListItem;
|
function GetItemAt(x,y: integer): TListItem;
|
||||||
|
|
||||||
|
|
||||||
|
{GetNearestItem is used to locate a list item from a position specified in
|
||||||
|
pixel coordinates relative to the top left corner of the list view.
|
||||||
|
It starts looking at the position specified by the Point parameter,
|
||||||
|
and moves in the direction indicated by the Direction parameter
|
||||||
|
until it locates a list item.If no item is found Nil is returned.}
|
||||||
|
function GetNearestItem(APoint: TPoint; Direction: TSearchDirection): TListItem;
|
||||||
|
|
||||||
|
{Used to find the next list item after StartItem in the direction
|
||||||
|
given by the Direction parameter.
|
||||||
|
Only items in the state indicated by the States parameter are considered.
|
||||||
|
If no item is found Nil is returned.}
|
||||||
|
function GetNextItem(StartItem: TListItem; Direction: TSearchDirection; States: TListItemStates): TListItem;
|
||||||
|
|
||||||
function IsEditing: Boolean; // Delphi compatibile function which returns if our listview editor is active
|
function IsEditing: Boolean; // Delphi compatibile function which returns if our listview editor is active
|
||||||
property BoundingRect: TRect read GetBoundingRect;
|
property BoundingRect: TRect read GetBoundingRect;
|
||||||
property BorderStyle default bsSingle;
|
property BorderStyle default bsSingle;
|
||||||
|
@ -1142,6 +1142,81 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomListView.GetNearestItem(APoint: TPoint;
|
||||||
|
Direction: TSearchDirection): TListItem;
|
||||||
|
var
|
||||||
|
AItem: TListItem;
|
||||||
|
AIndex: Integer;
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
AItem := GetItemAt(APoint.x, APoint.y);
|
||||||
|
if Assigned(AItem) then
|
||||||
|
begin
|
||||||
|
AIndex := AItem.Index;
|
||||||
|
case Direction of
|
||||||
|
sdAbove: if AIndex - 1 >= 0 then Result := Items[AIndex - 1];
|
||||||
|
sdBelow: if AIndex - 1 < Items.Count then
|
||||||
|
Result := Items[AIndex + 1];
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomListView.GetNextItem(StartItem: TListItem;
|
||||||
|
Direction: TSearchDirection; States: TListItemStates): TListItem;
|
||||||
|
var
|
||||||
|
ACount: Integer;
|
||||||
|
AIndex: Integer;
|
||||||
|
|
||||||
|
{TODO: create public property States which reads states of item}
|
||||||
|
function GetItemStatesInternal(AItem: TListItem): TListItemStates;
|
||||||
|
begin
|
||||||
|
Result := [];
|
||||||
|
if AItem.GetState(Ord(lisCut)) then
|
||||||
|
;
|
||||||
|
if AItem.GetState(Ord(lisDropTarget)) then
|
||||||
|
;
|
||||||
|
if AItem.GetState(Ord(lisSelected)) then
|
||||||
|
;
|
||||||
|
if AItem.GetState(Ord(lisFocused)) then
|
||||||
|
;
|
||||||
|
Result := AItem.FStates;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
if Assigned(StartItem) then
|
||||||
|
begin
|
||||||
|
AIndex := StartItem.Index;
|
||||||
|
ACount := Items.Count;
|
||||||
|
case Direction of
|
||||||
|
sdAbove: if (AIndex -1) >= 0 then Result := Items[AIndex - 1];
|
||||||
|
sdBelow: if (Aindex + 1) < ACount then Result := Items[AIndex + 1];
|
||||||
|
sdAll:
|
||||||
|
while True do
|
||||||
|
begin
|
||||||
|
inc(AIndex);
|
||||||
|
if AIndex = StartItem.Index then
|
||||||
|
begin
|
||||||
|
Result := nil;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
if AIndex >= ACount then
|
||||||
|
AIndex := -1;
|
||||||
|
if (AIndex >= 0) and (AIndex < ACount) then
|
||||||
|
begin
|
||||||
|
Result := Items[AIndex];
|
||||||
|
if GetItemStatesInternal(Result) - States = [] then
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if Result = nil then
|
||||||
|
exit;
|
||||||
|
if (GetItemStatesInternal(Result) * States = []) then
|
||||||
|
Result := nil;
|
||||||
|
end
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomListView.IsEditing: Boolean;
|
function TCustomListView.IsEditing: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := Assigned(Self.FEditor) and FEditor.Visible;
|
Result := Assigned(Self.FEditor) and FEditor.Visible;
|
||||||
|
Loading…
Reference in New Issue
Block a user