Skip to content

Commit 3d86612

Browse files
committed
Giving access to the StyleLookup of a StyledControl
1 parent c7b3aa7 commit 3d86612

File tree

1 file changed

+67
-4
lines changed

1 file changed

+67
-4
lines changed

Source/fmx/WrapFmxControls.pas

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface
66

77
uses
88
Classes, SysUtils, TypInfo, Types,
9-
Fmx.Controls,
9+
FMX.Types, FMX.Controls,
1010
PythonEngine, WrapDelphi, WrapDelphiClasses, WrapFmxTypes;
1111

1212
type
@@ -67,10 +67,25 @@ TControlsAccess = class(TContainerAccess)
6767
property Container : TControl read GetContainer;
6868
end;
6969

70-
implementation
70+
TPyDelphiStyledControl = class(TPyDelphiControl)
71+
private
72+
function GetDelphiObject: TStyledControl;
73+
procedure SetDelphiObject(const Value: TStyledControl);
74+
protected
75+
// Exposed Methods
76+
// Property Getters
77+
function Get_StyleLookup(AContext: Pointer): PPyObject; cdecl;
78+
// Property Setters
79+
function Set_StyleLookup(AValue: PPyObject; AContext: Pointer): integer; cdecl;
80+
public
81+
class function DelphiObjectClass: TClass; override;
82+
class procedure RegisterGetSets(PythonType: TPythonType); override;
83+
class procedure RegisterMethods(PythonType: TPythonType); override;
84+
// Properties
85+
property DelphiObject: TStyledControl read GetDelphiObject write SetDelphiObject;
86+
end;
7187

72-
uses
73-
FMX.Types;
88+
implementation
7489

7590
type
7691
{ Register the wrappers, the globals and the constants }
@@ -429,6 +444,54 @@ class function TControlsAccess.SupportsIndexOf: Boolean;
429444
Result := True;
430445
end;
431446

447+
{ TPyDelphiStyledControl }
448+
449+
class function TPyDelphiStyledControl.DelphiObjectClass: TClass;
450+
begin
451+
Result := TStyledControl;
452+
end;
453+
454+
function TPyDelphiStyledControl.GetDelphiObject: TStyledControl;
455+
begin
456+
Result := TStyledControl(inherited DelphiObject);
457+
end;
458+
459+
function TPyDelphiStyledControl.Get_StyleLookup(AContext: Pointer): PPyObject;
460+
begin
461+
Adjust(@Self);
462+
Result := GetPythonEngine.PyUnicodeFromString(DelphiObject.StyleLookup);
463+
end;
464+
465+
class procedure TPyDelphiStyledControl.RegisterGetSets(PythonType: TPythonType);
466+
begin
467+
inherited;
468+
end;
469+
470+
class procedure TPyDelphiStyledControl.RegisterMethods(PythonType: TPythonType);
471+
begin
472+
inherited;
473+
end;
474+
475+
procedure TPyDelphiStyledControl.SetDelphiObject(const Value: TStyledControl);
476+
begin
477+
inherited DelphiObject := Value;
478+
end;
479+
480+
function TPyDelphiStyledControl.Set_StyleLookup(AValue: PPyObject;
481+
AContext: Pointer): integer;
482+
var
483+
LValue: string;
484+
begin
485+
if CheckStrAttribute(AValue, 'StyleLookup', LValue) then
486+
with GetPythonEngine do begin
487+
Adjust(@Self);
488+
DelphiObject.StyleLookup := LValue;
489+
Result := 0;
490+
end
491+
else
492+
Result := -1;
493+
end;
494+
432495
initialization
433496
RegisteredUnits.Add(TControlsRegistration.Create);
434497

0 commit comments

Comments
 (0)