diff --git a/Modules/DelphiFMX/DelphiFMX.dpr b/Modules/DelphiFMX/DelphiFMX.dpr index 0e1ff9aa..262b73f0 100644 --- a/Modules/DelphiFMX/DelphiFMX.dpr +++ b/Modules/DelphiFMX/DelphiFMX.dpr @@ -1,6 +1,7 @@ library DelphiFMX; uses + System.StartUpCopy, SysUtils, Classes, uMain in 'uMain.pas'; diff --git a/Packages/Delphi/Delphi 10.4+/PythonFmx.dpk b/Packages/Delphi/Delphi 10.4+/PythonFmx.dpk index 755f6dd7..07851c0c 100644 --- a/Packages/Delphi/Delphi 10.4+/PythonFmx.dpk +++ b/Packages/Delphi/Delphi 10.4+/PythonFmx.dpk @@ -52,6 +52,7 @@ contains WrapFmxEdit in '..\..\..\Source\fmx\WrapFmxEdit.pas', WrapFmxListBox in '..\..\..\Source\fmx\WrapFmxListBox.pas', WrapFmxMedia in '..\..\..\Source\fmx\WrapFmxMedia.pas', - WrapFmxMenus in '..\..\..\Source\fmx\WrapFmxMenus.pas'; + WrapFmxMenus in '..\..\..\Source\fmx\WrapFmxMenus.pas', + WrapFmxStyles in '..\..\..\Source\fmx\WrapFmxStyles.pas'; end. diff --git a/Source/PythonEngine.pas b/Source/PythonEngine.pas index 0257a01a..c9064b08 100644 --- a/Source/PythonEngine.pas +++ b/Source/PythonEngine.pas @@ -95,8 +95,7 @@ interface {$IF not Defined(FPC) and (CompilerVersion >= 23)} const {$IF CompilerVersion >= 33} - pidSupportedPlatforms = pidWin32 or pidWin64 or pidOSX32 or pidOSX64 - or pidLinux64 or pidAndroid32Arm or pidAndroid64Arm; + pidSupportedPlatforms = pidAllPlatforms; {$ELSE} pidSupportedPlatforms = pidWin32 or pidWin64 or pidOSX32; {$IFEND} diff --git a/Source/fmx/WrapDelphiFmx.pas b/Source/fmx/WrapDelphiFmx.pas index 50ae14c4..1590cd9e 100644 --- a/Source/fmx/WrapDelphiFmx.pas +++ b/Source/fmx/WrapDelphiFmx.pas @@ -24,6 +24,7 @@ implementation WrapFmxScrollBox, WrapFmxGrids, WrapFmxMedia, - WrapFmxMenus; + WrapFmxMenus, + WrapFmxStyles; end. diff --git a/Source/fmx/WrapFmxListBox.pas b/Source/fmx/WrapFmxListBox.pas index 15077392..1f213f6d 100644 --- a/Source/fmx/WrapFmxListBox.pas +++ b/Source/fmx/WrapFmxListBox.pas @@ -40,6 +40,28 @@ TPyDelphiListBox = class(TPyDelphiCustomListBox) write SetDelphiObject; end; + TPyDelphiCustomComboBox = class(TPyDelphiStyledControl) + private + function GetDelphiObject: TCustomComboBox; + procedure SetDelphiObject(const Value: TCustomComboBox); + public + class function DelphiObjectClass: TClass; override; + // Properties + property DelphiObject: TCustomComboBox read GetDelphiObject + write SetDelphiObject; + end; + + TPyDelphiComboBox = class(TPyDelphiCustomComboBox) + private + function GetDelphiObject: TComboBox; + procedure SetDelphiObject(const Value: TComboBox); + public + class function DelphiObjectClass: TClass; override; + // Properties + property DelphiObject: TComboBox read GetDelphiObject + write SetDelphiObject; + end; + implementation uses @@ -73,6 +95,8 @@ procedure TListBoxRegistration.RegisterWrappers( APyDelphiWrapper.RegisterDelphiWrapper(TPyListBoxItem); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomListBox); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiListBox); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomComboBox); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiComboBox); end; { TPyListBoxItem } @@ -127,6 +151,40 @@ procedure TPyDelphiListBox.SetDelphiObject(const Value: TListBox); inherited DelphiObject := Value; end; +{ TPyDelphiCustomComboBox } + +class function TPyDelphiCustomComboBox.DelphiObjectClass: TClass; +begin + Result := TCustomComboBox; +end; + +function TPyDelphiCustomComboBox.GetDelphiObject: TCustomComboBox; +begin + Result := TCustomComboBox(inherited DelphiObject) +end; + +procedure TPyDelphiCustomComboBox.SetDelphiObject(const Value: TCustomComboBox); +begin + inherited DelphiObject := Value; +end; + +{ TPyDelphiComboBox } + +class function TPyDelphiComboBox.DelphiObjectClass: TClass; +begin + Result := TComboBox; +end; + +function TPyDelphiComboBox.GetDelphiObject: TComboBox; +begin + Result := TComboBox(inherited DelphiObject) +end; + +procedure TPyDelphiComboBox.SetDelphiObject(const Value: TComboBox); +begin + inherited DelphiObject := Value; +end; + initialization RegisteredUnits.Add(TListBoxRegistration.Create); diff --git a/Source/fmx/WrapFmxStyles.pas b/Source/fmx/WrapFmxStyles.pas new file mode 100644 index 00000000..b40aba05 --- /dev/null +++ b/Source/fmx/WrapFmxStyles.pas @@ -0,0 +1,156 @@ +{$I ..\Definition.Inc} + +unit WrapFmxStyles; + +interface + +uses + WrapDelphi, FMX.Styles, PythonEngine; + +type + TPyDelphiStyleStreaming = class(TPyDelphiObject) + private + function GetDelphiObject: TStyleStreaming; + procedure SetDelphiObject(const Value: TStyleStreaming); + public + constructor Create( APythonType : TPythonType ); override; + constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; + class function DelphiObjectClass : TClass; override; + class procedure RegisterGetSets(PythonType: TPythonType); override; + class procedure RegisterMethods(PythonType: TPythonType); override; + + property DelphiObject: TStyleStreaming read GetDelphiObject write SetDelphiObject; + end; + + TPyDelphiStyleManager = class(TPyDelphiObject) + private + function GetDelphiObject: TStyleManager; + procedure SetDelphiObject(const Value: TStyleManager); + public + constructor Create( APythonType : TPythonType ); override; + constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; + class function DelphiObjectClass : TClass; override; + class procedure RegisterGetSets(PythonType: TPythonType); override; + class procedure RegisterMethods(PythonType: TPythonType); override; + + property DelphiObject: TStyleManager read GetDelphiObject write SetDelphiObject; + end; + +implementation + +uses + FMX.Types; + +{ Register the wrappers, the globals and the constants } +type + TFmxStylesRegistration = class(TRegisteredUnit) + public + function Name: string; override; + procedure RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper); override; + procedure DefineVars(APyDelphiWrapper: TPyDelphiWrapper); override; + end; + +{ TFmxStylesRegistration } + +procedure TFmxStylesRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper); +begin + inherited; +end; + +function TFmxStylesRegistration.Name: string; +begin + Result := 'Styles'; +end; + +procedure TFmxStylesRegistration.RegisterWrappers( + APyDelphiWrapper: TPyDelphiWrapper); +begin + inherited; + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiStyleStreaming); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiStyleManager); +end; + +{ TPyDelphiStyleStreaming } + +constructor TPyDelphiStyleStreaming.Create(APythonType: TPythonType); +begin + inherited; +end; + +constructor TPyDelphiStyleStreaming.CreateWith(APythonType: TPythonType; + args: PPyObject); +begin + inherited; + DelphiObject := TStyleStreaming.Create(); +end; + +class function TPyDelphiStyleStreaming.DelphiObjectClass: TClass; +begin + Result := TStyleStreaming; +end; + +function TPyDelphiStyleStreaming.GetDelphiObject: TStyleStreaming; +begin + Result := TStyleStreaming(inherited DelphiObject); +end; + +class procedure TPyDelphiStyleStreaming.RegisterGetSets( + PythonType: TPythonType); +begin + inherited; +end; + +class procedure TPyDelphiStyleStreaming.RegisterMethods( + PythonType: TPythonType); +begin + inherited; +end; + +procedure TPyDelphiStyleStreaming.SetDelphiObject(const Value: TStyleStreaming); +begin + inherited DelphiObject := Value; +end; + +{ TPyDelphiStyleManager } + +constructor TPyDelphiStyleManager.Create(APythonType: TPythonType); +begin + inherited; +end; + +constructor TPyDelphiStyleManager.CreateWith(APythonType: TPythonType; + args: PPyObject); +begin + inherited; + DelphiObject := TStyleManager.Create(); +end; + +class function TPyDelphiStyleManager.DelphiObjectClass: TClass; +begin + Result := TStyleManager; +end; + +function TPyDelphiStyleManager.GetDelphiObject: TStyleManager; +begin + Result := TStyleManager(inherited DelphiObject); +end; + +class procedure TPyDelphiStyleManager.RegisterGetSets(PythonType: TPythonType); +begin + inherited; +end; + +class procedure TPyDelphiStyleManager.RegisterMethods(PythonType: TPythonType); +begin + inherited; +end; + +procedure TPyDelphiStyleManager.SetDelphiObject(const Value: TStyleManager); +begin + inherited DelphiObject := Value; +end; + +initialization + RegisteredUnits.Add(TFmxStylesRegistration.Create()); + +end. diff --git a/Source/fmx/WrapFmxTypes.pas b/Source/fmx/WrapFmxTypes.pas index bb74f180..b87245a5 100644 --- a/Source/fmx/WrapFmxTypes.pas +++ b/Source/fmx/WrapFmxTypes.pas @@ -1,5 +1,4 @@ {$I ..\Definition.Inc} - unit WrapFmxTypes; interface @@ -23,14 +22,11 @@ TPyDelphiPointF = class(TPyObject) function Set_X(AValue: PPyObject; AContext: Pointer): integer; cdecl; function Set_Y(AValue: PPyObject; AContext: Pointer): integer; cdecl; public - constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; - + constructor CreateWith(APythonType: TPythonType; Args: PPyObject); override; function Compare(obj: PPyObject): Integer; override; function Repr: PPyObject; override; - class procedure RegisterGetSets(PythonType: TPythonType); override; class procedure SetupType(PythonType: TPythonType); override; - property Value : TPointF read FValue write FValue; end; @@ -46,16 +42,36 @@ TPyDelphiSizeF = class(TPyObject) function Set_Height(AValue: PPyObject; AContext: Pointer): integer; cdecl; public constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; - function Compare(obj: PPyObject): Integer; override; function Repr: PPyObject; override; - class procedure RegisterGetSets(PythonType: TPythonType); override; class procedure SetupType(PythonType: TPythonType); override; - property Value : TSizeF read FValue write FValue; end; + TPyDelphiRectF = class(TPyObject) + private + FValue: TRectF; + protected + // Exposed Getters + function Get_Top(Acontext: Pointer): PPyObject; cdecl; + function Get_Bottom(Acontext: Pointer): PPyObject; cdecl; + function Get_Left(Acontext: Pointer): PPyObject; cdecl; + function Get_Right(Acontext: Pointer): PPyObject; cdecl; + // Exposed Setters + function Set_Top(AValue: PPyObject; AContext: Pointer): integer; cdecl; + function Set_Bottom(AValue: PPyObject; AContext: Pointer): integer; cdecl; + function Set_Left(AValue: PPyObject; AContext: Pointer): integer; cdecl; + function Set_Right(AValue: PPyObject; AContext: Pointer): integer; cdecl; + public + constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; + function Compare(obj: PPyObject): Integer; override; + function Repr: PPyObject; override; + class procedure RegisterGetSets(PythonType: TPythonType); override; + class procedure SetupType(PythonType: TPythonType); override; + property Value: TRectF read FValue write FValue; + end; + TPyDelphiFmxObject = class(TPyDelphiComponent) private function GetDelphiObject: TFmxObject; @@ -87,6 +103,7 @@ TPyDelphiPosition = class(TPyDelphiPersistent) function Set_Y(AValue: PPyObject; AContext: Pointer): integer; cdecl; function Set_Point(AValue: PPyObject; AContext: Pointer): integer; cdecl; public + constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; class function DelphiObjectClass: TClass; override; class procedure RegisterMethods(PythonType: TPythonType); override; class procedure RegisterGetSets(PythonType: TPythonType); override; @@ -103,11 +120,41 @@ TPyDelphiCustomPopupMenu = class(TPyDelphiFMXObject) property DelphiObject: TCustomPopupMenu read GetDelphiObject write SetDelphiObject; end; + TPyDelphiBounds = class(TPyDelphiPersistent) + private + function GetDelphiObject: TBounds; + procedure SetDelphiObject(const Value: TBounds); + protected + function Get_Rect(Acontext: Pointer): PPyObject; cdecl; + function Set_Rect(AValue: PPyObject; AContext: Pointer): integer; cdecl; + public + constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; + class function DelphiObjectClass: TClass; override; + class procedure RegisterGetSets(PythonType: TPythonType); override; + property DelphiObject: TBounds read GetDelphiObject write SetDelphiObject; + end; + + TPyDelphiControlSize = class(TPyDelphiPersistent) + private + function GetDelphiObject: TControlSize; + procedure SetDelphiObject(const Value: TControlSize); + protected + function Get_SizeF(Acontext: Pointer): PPyObject; cdecl; + function Set_SizeF(AValue: PPyObject; AContext: Pointer): integer; cdecl; + public + constructor CreateWith(APythonType: TPythonType; args: PPyObject); override; + class function DelphiObjectClass: TClass; override; + class procedure RegisterGetSets(PythonType: TPythonType); override; + property DelphiObject: TControlSize read GetDelphiObject write SetDelphiObject; + end; + {Helper functions} function WrapPointF(APyDelphiWrapper: TPyDelphiWrapper; const APoint : TPointF) : PPyObject; function WrapSizeF(APyDelphiWrapper: TPyDelphiWrapper; const ASize : TSizeF) : PPyObject; - function CheckPointFAttribute(AAttribute : PPyObject; const AAttributeName : string; out AValue : TPointF) : Boolean; - function CheckSizeFAttribute(AAttribute : PPyObject; const AAttributeName : string; out AValue : TSizeF) : Boolean; + function WrapRectF(APyDelphiWrapper: TPyDelphiWrapper; const ARect : TRectF) : PPyObject; + function CheckPointFAttribute(AAttribute: PPyObject; const AAttributeName: string; out AValue: TPointF): Boolean; + function CheckSizeFAttribute(AAttribute: PPyObject; const AAttributeName: string; out AValue: TSizeF): Boolean; + function CheckRectFAttribute(AAttribute: PPyObject; const AAttributeName: string; out AValue: TRectF): Boolean; implementation @@ -141,7 +188,7 @@ function TPyDelphiPointF.Compare(obj: PPyObject): Integer; end; constructor TPyDelphiPointF.CreateWith(APythonType: TPythonType; - args: PPyObject); + Args: PPyObject); var x, y : single; begin @@ -240,9 +287,12 @@ procedure TTypesRegistration.RegisterWrappers( inherited; APyDelphiWrapper.RegisterHelperType(TPyDelphiPointF); APyDelphiWrapper.RegisterHelperType(TPyDelphiSizeF); + APyDelphiWrapper.RegisterHelperType(TPyDelphiRectF); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiFmxObject); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiPosition); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomPopupMenu); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiBounds); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiControlSize); end; { Helper functions } @@ -264,6 +314,15 @@ function WrapSizeF(APyDelphiWrapper: TPyDelphiWrapper; const ASize : TSizeF) : P (PythonToDelphi(Result) as TPyDelphiSizeF).Value := ASize; end; +function WrapRectF(APyDelphiWrapper: TPyDelphiWrapper; const ARect : TRectF) : PPyObject; +var + LType : TPythonType; +begin + LType := APyDelphiWrapper.GetHelperType('RectFType'); + Result := LType.CreateInstance; + (PythonToDelphi(Result) as TPyDelphiRectF).Value := ARect; +end; + function CheckPointFAttribute(AAttribute : PPyObject; const AAttributeName : string; out AValue : TPointF) : Boolean; begin with GetPythonEngine do @@ -302,6 +361,25 @@ function CheckSizeFAttribute(AAttribute : PPyObject; const AAttributeName : stri end; end; +function CheckRectFAttribute(AAttribute: PPyObject; const AAttributeName: string; out AValue: TRectF): Boolean; +begin + with GetPythonEngine do + begin + if IsDelphiObject(AAttribute) and (PythonToDelphi(AAttribute) is TPyDelphiRectF) then + begin + AValue := TPyDelphiRectF(PythonToDelphi(AAttribute)).Value; + Result := True; + end + else + begin + Result := False; + with GetPythonEngine do + PyErr_SetString (PyExc_AttributeError^, + PAnsiChar(AnsiString(Format('%s receives only RectF objects', [AAttributeName])))); + end; + end; +end; + { TPyDelphiFmxObject } class function TPyDelphiFmxObject.DelphiObjectClass: TClass; @@ -354,6 +432,18 @@ function TPyDelphiFmxObject.Set_Parent(AValue: PPyObject; { TPyDelphiPosition } +constructor TPyDelphiPosition.CreateWith(APythonType: TPythonType; + args: PPyObject); +var + LPPosition: PPyObject; + LPointF: TPointF; +begin + inherited; + if APythonType.Engine.PyArg_ParseTuple(args, 'O:Create', @LPPosition) <> 0 then + if CheckPointFAttribute(LPPosition, 'PointF', LPointF) then + DelphiObject := TPosition.Create(LPointF); +end; + class function TPyDelphiPosition.DelphiObjectClass: TClass; begin Result := TPosition; @@ -533,7 +623,6 @@ function TPyDelphiSizeF.Set_Height(AValue: PPyObject; else Result := -1; end; - function TPyDelphiSizeF.Set_Width(AValue: PPyObject; AContext: Pointer): integer; var @@ -548,7 +637,6 @@ function TPyDelphiSizeF.Set_Width(AValue: PPyObject; else Result := -1; end; - { TPyDelphiCustomPopupMenu } class function TPyDelphiCustomPopupMenu.DelphiObjectClass: TClass; @@ -567,6 +655,272 @@ procedure TPyDelphiCustomPopupMenu.SetDelphiObject( inherited DelphiObject := Value; end; +{ TPyDelphiBounds } + +constructor TPyDelphiBounds.CreateWith(APythonType: TPythonType; + args: PPyObject); +var + LPBounds: PPyObject; + LRectF: TRectF; +begin + inherited; + if APythonType.Engine.PyArg_ParseTuple(args, 'O:Create', @LPBounds) <> 0 then + if CheckRectFAttribute(LPBounds, 'RectF', LRectF) then + DelphiObject := TBounds.Create(LRectF); +end; + +class function TPyDelphiBounds.DelphiObjectClass: TClass; +begin + Result := TBounds +end; + +function TPyDelphiBounds.GetDelphiObject: TBounds; +begin + Result := TBounds(inherited DelphiObject); +end; + +function TPyDelphiBounds.Get_Rect(Acontext: Pointer): PPyObject; +begin + Adjust(@Self); + Result := WrapRectF(PyDelphiWrapper, DelphiObject.Rect); +end; + +class procedure TPyDelphiBounds.RegisterGetSets(PythonType: TPythonType); +begin + inherited; + with PythonType do begin + AddGetSet('Rect', @TPyDelphiBounds.Get_Rect, @TPyDelphiBounds.Set_Rect, + 'Provides access to the rect of a control', nil); + end; +end; + +procedure TPyDelphiBounds.SetDelphiObject(const Value: TBounds); +begin + inherited DelphiObject := Value; +end; + +function TPyDelphiBounds.Set_Rect(AValue: PPyObject; + AContext: Pointer): integer; +var + LValue: TRectF; +begin + Adjust(@Self); + if CheckRectFAttribute(AValue, 'Rect', LValue) then + begin + DelphiObject.Rect := LValue; + Result := 0; + end + else + Result := -1; +end; + +{ TPyDelphiControlSize } + +constructor TPyDelphiControlSize.CreateWith(APythonType: TPythonType; + args: PPyObject); +var + LPControlSize: PPyObject; + LSizeF: TSizeF; +begin + inherited; + if APythonType.Engine.PyArg_ParseTuple(args, 'O:Create', @LPControlSize) <> 0 then + if CheckSizeFAttribute(LPControlSize, 'SizeF', LSizeF) then + DelphiObject := TControlSize.Create(LSizeF); +end; + +class function TPyDelphiControlSize.DelphiObjectClass: TClass; +begin + Result := TControlSize; +end; + +function TPyDelphiControlSize.GetDelphiObject: TControlSize; +begin + Result := TControlSize(inherited DelphiObject); +end; + +function TPyDelphiControlSize.Get_SizeF(Acontext: Pointer): PPyObject; +begin + Adjust(@Self); + Result := WrapSizeF(PyDelphiWrapper, DelphiObject.Size); +end; + +class procedure TPyDelphiControlSize.RegisterGetSets(PythonType: TPythonType); +begin + inherited; + with PythonType do begin + AddGetSet('Size', @TPyDelphiControlSize.Get_SizeF, @TPyDelphiControlSize.Set_SizeF, + 'Provides access to the size of a control', nil); + end; +end; + +procedure TPyDelphiControlSize.SetDelphiObject(const Value: TControlSize); +begin + inherited DelphiObject := Value; +end; + +function TPyDelphiControlSize.Set_SizeF(AValue: PPyObject; + AContext: Pointer): integer; +var + LValue: TSizeF; +begin + Adjust(@Self); + if CheckSizeFAttribute(AValue, 'Size', LValue) then + begin + DelphiObject.Size := LValue; + Result := 0; + end + else + Result := -1; +end; + +{ TPyDelphiRectF } + +function TPyDelphiRectF.Compare(obj: PPyObject): Integer; +var + LOther : TPyDelphiRectF; +begin + if IsDelphiObject(obj) and (PythonToDelphi(obj) is TPyDelphiPointF) then + begin + LOther := TPyDelphiRectF(PythonToDelphi(obj)); + Result := CompareValue(Value.Left, LOther.Value.Left) + and CompareValue(Value.Top, LOther.Value.Top) + and CompareValue(Value.Right, LOther.Value.Right) + and CompareValue(Value.Bottom, LOther.Value.Bottom); + end + else + Result := 1; +end; + +constructor TPyDelphiRectF.CreateWith(APythonType: TPythonType; + args: PPyObject); +var + LLeft, LTop, LRight, LBottom : single; +begin + inherited; + if APythonType.Engine.PyArg_ParseTuple(args, 'ffff:Create', @LLeft, @LTop, @LRight, @LBottom) <> 0 then + begin + FValue.Left := LLeft; + FValue.Top := LTop; + FValue.Right := LRight; + FValue.Bottom := LBottom; + end +end; + +function TPyDelphiRectF.Get_Bottom(Acontext: Pointer): PPyObject; +begin + Adjust(@Self); + Result := GetPythonEngine.PyFloat_FromDouble(Value.Bottom); +end; + +function TPyDelphiRectF.Get_Left(Acontext: Pointer): PPyObject; +begin + Adjust(@Self); + Result := GetPythonEngine.PyFloat_FromDouble(Value.Left); +end; + +function TPyDelphiRectF.Get_Right(Acontext: Pointer): PPyObject; +begin + Adjust(@Self); + Result := GetPythonEngine.PyFloat_FromDouble(Value.Right); +end; + +function TPyDelphiRectF.Get_Top(Acontext: Pointer): PPyObject; +begin + Adjust(@Self); + Result := GetPythonEngine.PyFloat_FromDouble(Value.Top); +end; + +class procedure TPyDelphiRectF.RegisterGetSets(PythonType: TPythonType); +begin + inherited; + with PythonType do + begin + AddGetSet('Left', @TPyDelphiRectF.Get_Left, @TPyDelphiRectF.Set_Left, + 'Provides access to the left of a rectf', nil); + AddGetSet('Top', @TPyDelphiRectF.Get_Top, @TPyDelphiRectF.Set_Top, + 'Provides access to the top of a rectf', nil); + AddGetSet('Right', @TPyDelphiRectF.Get_Right, @TPyDelphiRectF.Set_Right, + 'Provides access to the right of a rectf', nil); + AddGetSet('Bottom', @TPyDelphiRectF.Get_Bottom, @TPyDelphiRectF.Set_Bottom, + 'Provides access to the bottom of a rectf', nil); + end; +end; + +function TPyDelphiRectF.Repr: PPyObject; +begin + Result := GetPythonEngine.PyUnicodeFromString(Format('', + [Value.Left, Value.Top, Value.Right, Value.Bottom])); +end; + +class procedure TPyDelphiRectF.SetupType(PythonType: TPythonType); +begin + inherited; + PythonType.TypeName := 'RectF'; + PythonType.Name := string(PythonType.TypeName) + TPythonType.TYPE_COMP_NAME_SUFFIX; + PythonType.TypeFlags := PythonType.TypeFlags + [tpfBaseType]; + PythonType.GenerateCreateFunction := False; + PythonType.DocString.Text := 'wrapper for Delphi FMX TRectF type'; + PythonType.Services.Basic := [bsGetAttrO, bsSetAttrO, bsRepr, bsStr, bsRichCompare]; +end; + +function TPyDelphiRectF.Set_Bottom(AValue: PPyObject; + AContext: Pointer): integer; +var + LValue: double; +begin + if CheckFloatAttribute(AValue, 'Bottom', LValue) then + with GetPythonEngine do begin + Adjust(@Self); + FValue.Bottom := LValue; + Result := 0; + end + else + Result := -1; +end; + +function TPyDelphiRectF.Set_Left(AValue: PPyObject; AContext: Pointer): integer; +var + LValue: double; +begin + if CheckFloatAttribute(AValue, 'Left', LValue) then + with GetPythonEngine do begin + Adjust(@Self); + FValue.Left := LValue; + Result := 0; + end + else + Result := -1; +end; + +function TPyDelphiRectF.Set_Right(AValue: PPyObject; + AContext: Pointer): integer; +var + LValue: double; +begin + if CheckFloatAttribute(AValue, 'Right', LValue) then + with GetPythonEngine do begin + Adjust(@Self); + FValue.Right := LValue; + Result := 0; + end + else + Result := -1; +end; + +function TPyDelphiRectF.Set_Top(AValue: PPyObject; AContext: Pointer): integer; +var + LValue: double; +begin + if CheckFloatAttribute(AValue, 'Top', LValue) then + with GetPythonEngine do begin + Adjust(@Self); + FValue.Top := LValue; + Result := 0; + end + else + Result := -1; +end; + initialization RegisteredUnits.Add(TTypesRegistration.Create);