mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 15:09:24 +02:00
Gtk3: do not append scrollbars offset to the TGtk3ListBox.GetItemRect(), implemented TGtk3ListBox.GetIndexAtXY(), TGtk3WSCustomListBox.GetIndexAtXY()
This commit is contained in:
parent
1d07d268ed
commit
b0a562be0d
@ -553,6 +553,7 @@ type
|
|||||||
function GetSelCount: Integer;
|
function GetSelCount: Integer;
|
||||||
function GetSelection: PGtkTreeSelection;
|
function GetSelection: PGtkTreeSelection;
|
||||||
function GetItemRect(const AIndex: integer): TRect;
|
function GetItemRect(const AIndex: integer): TRect;
|
||||||
|
function GetIndexAtXY(const X, Y: integer): integer;
|
||||||
function GetItemSelected(const AIndex: Integer): Boolean;
|
function GetItemSelected(const AIndex: Integer): Boolean;
|
||||||
procedure SelectItem(const AIndex: Integer; ASelected: Boolean);
|
procedure SelectItem(const AIndex: Integer; ASelected: Boolean);
|
||||||
procedure SetTopIndex(const AIndex: Integer);
|
procedure SetTopIndex(const AIndex: Integer);
|
||||||
@ -5641,15 +5642,30 @@ begin
|
|||||||
AModel := PGtkTreeView(getContainerWidget)^.model;
|
AModel := PGtkTreeView(getContainerWidget)^.model;
|
||||||
if AModel = nil then
|
if AModel = nil then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if AModel^.iter_nth_child(@Iter, nil, AIndex) then
|
if AModel^.iter_nth_child(@Iter, nil, AIndex) then
|
||||||
begin
|
begin
|
||||||
ACol := gtk_tree_view_get_column(PGtkTreeView(getContainerWidget), 0)^;
|
ACol := gtk_tree_view_get_column(PGtkTreeView(getContainerWidget), 0)^;
|
||||||
gtk_tree_view_get_cell_area(PGtkTreeView(getContainerWidget), AModel^.get_path(@Iter), @ACol, @AGdkRect);
|
gtk_tree_view_get_cell_area(PGtkTreeView(getContainerWidget), AModel^.get_path(@Iter), @ACol, @AGdkRect);
|
||||||
Result := RectFromGdkRect(AGdkRect);
|
Result := RectFromGdkRect(AGdkRect);
|
||||||
if getVerticalScrollbar^.visible then
|
end;
|
||||||
Types.OffsetRect(Result, 0, Round(getVerticalScrollbar^.get_value));
|
end;
|
||||||
if getHorizontalScrollbar^.visible then
|
|
||||||
Types.OffsetRect(Result, Round(getHorizontalScrollbar^.get_value), 0);
|
function TGtk3ListBox.GetIndexAtXY(const X, Y: integer): integer;
|
||||||
|
var
|
||||||
|
Path: PGtkTreePath;
|
||||||
|
Column: PGtkTreeViewColumn;
|
||||||
|
CellX, CellY: Integer;
|
||||||
|
Indices: PInteger;
|
||||||
|
begin
|
||||||
|
Result := -1;
|
||||||
|
if gtk_tree_view_get_path_at_pos(PGtkTreeView(getContainerWidget), X, Y,
|
||||||
|
@Path, @Column, @CellX, @CellY) then
|
||||||
|
begin
|
||||||
|
Indices := gtk_tree_path_get_indices(Path);
|
||||||
|
if Assigned(Indices) then
|
||||||
|
Result := Indices^;
|
||||||
|
gtk_tree_path_free(Path);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -401,8 +401,14 @@ end;
|
|||||||
|
|
||||||
class function TGtk3WSCustomListBox.GetIndexAtXY(
|
class function TGtk3WSCustomListBox.GetIndexAtXY(
|
||||||
const ACustomListBox: TCustomListBox; X, Y: integer): integer;
|
const ACustomListBox: TCustomListBox; X, Y: integer): integer;
|
||||||
|
var
|
||||||
|
Widget: TGtk3ListBox;
|
||||||
begin
|
begin
|
||||||
Result := -1;
|
Result := -1;
|
||||||
|
if not WSCheckHandleAllocated(ACustomListBox, 'GetIndexAtXY') then
|
||||||
|
exit;
|
||||||
|
Widget := TGtk3ListBox(ACustomListBox.Handle);
|
||||||
|
Result := Widget.GetIndexAtXY(X, Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TGtk3WSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
|
class function TGtk3WSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user