cocoa: common code to determine a rect of a cell in NSTableView

git-svn-id: trunk@58997 -
This commit is contained in:
dmitry 2018-09-14 22:42:01 +00:00
parent fac617af9b
commit 463f479224
3 changed files with 19 additions and 14 deletions

View File

@ -235,6 +235,7 @@ type
function AllocCocoaTableListView: TCocoaTableListView;
function LCLCoordToRow(tbl: NSTableView; X,Y: Integer): Integer;
function LCLGetItemRect(tbl: NSTableView; row, col: Integer; var r: TRect): Boolean;
implementation
@ -256,6 +257,20 @@ begin
Result := tbl.rowAtPoint(pt);
end;
function LCLGetItemRect(tbl: NSTableView; row, col: Integer; var r: TRect): Boolean;
var
nsr : NSRect;
begin
if not Assigned(tbl) then begin
Result := false;
r := Bounds(0,0,0,0);
Exit;
end;
nsr:=tbl.frameOfCellAtColumn_row(col,row);
r:=NSRectToRect(nsr);
Result := True;
end;
// not yet!
{.$DEFINE DYNAMIC_NSTABLEVIEW_BASE}

View File

@ -1013,17 +1013,10 @@ class function TCocoaWSCustomListView.ItemDisplayRect(
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
lRowRect, lColRect, lNSRect: NSRect;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then
begin
Result:=Bounds(0,0,0,0);
Exit;
end;
lRowRect := lTableLV.rectOfRow(AIndex);
lColRect := lTableLV.rectOfColumn(ASubItem);
lNSRect := NSIntersectionRect(lRowRect, lColRect);
NSToLCLRect(lNSRect, lCocoaLV.frame.size.height, Result);
Result:=Bounds(0,0,0,0);
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
LCLGetItemRect(lTableLV, AIndex, ASubItem, Result);
end;
class function TCocoaWSCustomListView.ItemGetChecked(

View File

@ -1819,10 +1819,7 @@ begin
view := GetListBox(ACustomListBox);
if not Assigned(view) then Exit(False);
r:=view.frameOfCellAtColumn_row(0,index);
Arect:=NSRectToRect(r);
Result := True;
Result := LCLGetItemRect(view, Index, 0, ARect);
end;
class function TCocoaWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;