Skip to content

Commit cf2d86c

Browse files
committed
Added access to the RowHeights property
1 parent db48eea commit cf2d86c

File tree

1 file changed

+71
-4
lines changed

1 file changed

+71
-4
lines changed

Source/WrapDelphiGrids.pas

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ TGridColWidthsAccess = class(TContainerAccess)
4343
property Container : TCustomDrawGrid read GetContainer;
4444
end;
4545

46+
TGridRowHeightsAccess = class(TContainerAccess)
47+
private
48+
function GetContainer: TCustomDrawGrid;
49+
public
50+
function GetItem(AIndex : Integer) : PPyObject; override;
51+
function GetSize : Integer; override;
52+
function SetItem(AIndex : Integer; AValue : PPyObject) : Boolean; override;
53+
54+
class function ExpectedContainerClass : TClass; override;
55+
class function SupportsWrite : Boolean; override;
56+
class function Name : string; override;
57+
58+
property Container : TCustomDrawGrid read GetContainer;
59+
end;
60+
4661
TPyDelphiCustomGrid = class (TPyDelphiWinControl)
4762
private
4863
function GetDelphiObject: TCustomGrid;
@@ -73,7 +88,7 @@ TPyDelphiCustomDrawGrid = class (TPyDelphiCustomGrid)
7388
function Get_LeftCol(AContext : Pointer): PPyObject; cdecl;
7489
function Get_Selection(AContext : Pointer): PPyObject; cdecl;
7590
function Get_Row(AContext : Pointer): PPyObject; cdecl;
76-
//function Get_RowHeights(AContext : Pointer): PPyObject; cdecl;
91+
function Get_RowHeights(AContext : Pointer): PPyObject; cdecl;
7792
//function Get_TabStops(AContext : Pointer): PPyObject; cdecl;
7893
function Get_TopRow(AContext : Pointer): PPyObject; cdecl;
7994

@@ -307,6 +322,9 @@ class function TSelectCellEventHandler.GetTypeInfo: PTypeInfo;
307322

308323
{ TGridColWidthsAccess }
309324

325+
type
326+
TCustomDrawGridAccess = class(TCustomDrawGrid);
327+
310328
class function TGridColWidthsAccess.ExpectedContainerClass: TClass;
311329
begin
312330
result:=TCustomGrid;
@@ -323,9 +341,6 @@ function TGridColWidthsAccess.GetItem(AIndex: Integer): PPyObject;
323341
Result:=PyLong_FromLong(Container.ColWidths[AIndex]);
324342
end;
325343

326-
type
327-
TCustomDrawGridAccess = class(TCustomDrawGrid);
328-
329344
function TGridColWidthsAccess.GetSize: Integer;
330345
begin
331346
result:=TCustomDrawGridAccess(Container).ColCount;
@@ -349,6 +364,47 @@ class function TGridColWidthsAccess.SupportsWrite: Boolean;
349364
result:=True;
350365
end;
351366

367+
{ TGridRowHeightsAccess }
368+
369+
class function TGridRowHeightsAccess.ExpectedContainerClass: TClass;
370+
begin
371+
result:=TCustomGrid;
372+
end;
373+
374+
function TGridRowHeightsAccess.GetContainer: TCustomDrawGrid;
375+
begin
376+
result:=TCustomDrawGrid(inherited Container);
377+
end;
378+
379+
function TGridRowHeightsAccess.GetItem(AIndex: Integer): PPyObject;
380+
begin
381+
with GetPythonEngine do
382+
Result:=PyLong_FromLong(Container.RowHeights[AIndex]);
383+
end;
384+
385+
function TGridRowHeightsAccess.GetSize: Integer;
386+
begin
387+
result:=TCustomDrawGridAccess(Container).RowCount;
388+
end;
389+
390+
class function TGridRowHeightsAccess.Name: string;
391+
begin
392+
result:='TCustomGrid.RowHeights';
393+
end;
394+
395+
function TGridRowHeightsAccess.SetItem(AIndex: Integer;
396+
AValue: PPyObject): Boolean;
397+
begin
398+
result:=True;
399+
with GetPythonEngine do
400+
Container.RowHeights[AIndex]:=PyLong_AsLong(AValue);
401+
end;
402+
403+
class function TGridRowHeightsAccess.SupportsWrite: Boolean;
404+
begin
405+
result:=True;
406+
end;
407+
352408
{ TPyDelphiCustomGrid }
353409

354410
class function TPyDelphiCustomGrid.DelphiObjectClass: TClass;
@@ -432,6 +488,15 @@ function TPyDelphiCustomDrawGrid.Get_Row(AContext: Pointer): PPyObject;
432488
Result := GetPythonEngine.PyLong_FromLong(DelphiObject.Row);
433489
end;
434490

491+
function TPyDelphiCustomDrawGrid.Get_RowHeights(
492+
AContext: Pointer): PPyObject;
493+
begin
494+
Adjust(@Self);
495+
Result := Self.PyDelphiWrapper.DefaultContainerType.CreateInstance;
496+
with PythonToDelphi(Result) as TPyDelphiContainer do
497+
Setup(Self.PyDelphiWrapper, TGridRowHeightsAccess.Create(Self.PyDelphiWrapper, Self.DelphiObject));
498+
end;
499+
435500
function TPyDelphiCustomDrawGrid.Get_Selection(
436501
AContext: Pointer): PPyObject;
437502
begin
@@ -474,6 +539,8 @@ class procedure TPyDelphiCustomDrawGrid.RegisterGetSets(
474539
'Indicates the boundaries of the current selection.', nil);
475540
AddGetSet('Row', @TPyDelphiCustomDrawGrid.Get_Row, @TPyDelphiCustomDrawGrid.Set_Row,
476541
'Specifies the index of the row that contains the selected cell.', nil);
542+
AddGetSet('RowHeights', @TPyDelphiCustomDrawGrid.Get_RowHeights, nil,
543+
'Specifies row heights of the grid', nil);
477544
AddGetSet('TopRow', @TPyDelphiCustomDrawGrid.Get_TopRow, @TPyDelphiCustomDrawGrid.Set_TopRow,
478545
'Specifies the index of the first visible scrollable row in the grid.', nil);
479546
end;

0 commit comments

Comments
 (0)