From 6f8ec5099151ed3d05611566670c1250293127f0 Mon Sep 17 00:00:00 2001 From: Lucas Moura Belo Date: Mon, 21 Dec 2020 10:17:33 -0300 Subject: [PATCH 1/4] Adding FMX.Dialogs.TOpenDialog wrapper --- Source/fmx/WrapFmxDialogs.pas | 114 ++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Source/fmx/WrapFmxDialogs.pas diff --git a/Source/fmx/WrapFmxDialogs.pas b/Source/fmx/WrapFmxDialogs.pas new file mode 100644 index 00000000..8302e619 --- /dev/null +++ b/Source/fmx/WrapFmxDialogs.pas @@ -0,0 +1,114 @@ +unit WrapFmxDialogs; + +interface + +uses + FMX.Dialogs, WrapDelphiClasses, PythonEngine; + + +type + TPyDelphiOpenDialog = class(TPyDelphiComponent) + private + function GetDelphiObject: TOpenDialog; + procedure SetDelphiObject(const Value: TOpenDialog); + protected + // Exposed Methods + function Execute_Wrapper(args: PPyObject): PPyObject; cdecl; + // Property Getters + function Get_filename(AContext: Pointer): PPyObject; cdecl; + public + class function DelphiObjectClass: TClass; override; + class procedure RegisterGetSets(PythonType: TPythonType); override; + class procedure RegisterMethods( PythonType : TPythonType ); override; + // Properties + property DelphiObject: TOpenDialog read GetDelphiObject + write SetDelphiObject; + end; + +implementation + +uses + WrapDelphi; + +{ Register the wrappers, the globals and the constants } +type + TDialogRegistration = class(TRegisteredUnit) + public + function Name: string; override; + procedure RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper); override; + procedure DefineVars(APyDelphiWrapper: TPyDelphiWrapper); override; + end; + +{ TDialogRegistration } + +procedure TDialogRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper); +begin + inherited; +end; + +function TDialogRegistration.Name: string; +begin + Result := 'Dialog'; +end; + +procedure TDialogRegistration.RegisterWrappers( + APyDelphiWrapper: TPyDelphiWrapper); +begin + inherited; + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiOpenDialog); +end; + +{ TPyDelphiOpenDialog } + +class function TPyDelphiOpenDialog.DelphiObjectClass: TClass; +begin + Result := TOpenDialog; +end; + +function TPyDelphiOpenDialog.Execute_Wrapper(args: PPyObject): PPyObject; +begin + // We adjust the transmitted self argument + Adjust(@Self); + with GetPythonEngine do begin + if PyArg_ParseTuple( args, ':Execute') <> 0 then + Result := VariantAsPyObject(DelphiObject.Execute()) + else + Result := nil; + end; +end; + +function TPyDelphiOpenDialog.GetDelphiObject: TOpenDialog; +begin + Result := TOpenDialog(inherited DelphiObject); +end; + +function TPyDelphiOpenDialog.Get_filename(AContext: Pointer): PPyObject; +begin + Adjust(@self); + Result := GetPythonEngine.VariantAsPyObject(DelphiObject.FileName); +end; + +class procedure TPyDelphiOpenDialog.RegisterGetSets(PythonType: TPythonType); +begin + inherited; + PythonType.AddGetSet('FileName', @TPyDelphiOpenDialog.Get_filename, + nil, '', nil); +end; + +class procedure TPyDelphiOpenDialog.RegisterMethods(PythonType: TPythonType); +begin + inherited; + PythonType.AddMethod('Execute', @TPyDelphiOpenDialog.Execute_Wrapper, + 'TOpenDialog.Execute()'#10 + + 'Displays the dialog'); +end; + +procedure TPyDelphiOpenDialog.SetDelphiObject(const Value: TOpenDialog); +begin + inherited DelphiObject := Value; +end; + +initialization + RegisteredUnits.Add(TDialogRegistration.Create); + +end. From 6b51d5edf021b0f1ab4cc43adf9328e40a97139f Mon Sep 17 00:00:00 2001 From: Lucas Moura Belo Date: Mon, 21 Dec 2020 10:53:18 -0300 Subject: [PATCH 2/4] Adding TTabControl wrapper --- Source/fmx/WrapFmxComCtrls.pas | 129 +++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 Source/fmx/WrapFmxComCtrls.pas diff --git a/Source/fmx/WrapFmxComCtrls.pas b/Source/fmx/WrapFmxComCtrls.pas new file mode 100644 index 00000000..21f98957 --- /dev/null +++ b/Source/fmx/WrapFmxComCtrls.pas @@ -0,0 +1,129 @@ +unit WrapFmxComCtrls; + +interface + +uses + FMX.Controls.Presentation, FMX.MultiView, FMX.TabControl, WrapFmxControls; + +type + TPyDelphiTabControl = class(TPyDelphiStyledControl) + private + function GetDelphiObject: TTabControl; + procedure SetDelphiObject(const Value: TTabControl); + public + class function DelphiObjectClass: TClass; override; + // Properties + property DelphiObject: TTabControl read GetDelphiObject write SetDelphiObject; + end; + + TPyDelphiCustomMultiView = class(TPyDelphiPresentedControl) + private + function GetDelphiObject: TCustomMultiView; + procedure SetDelphiObject(const Value: TCustomMultiView); + public + class function DelphiObjectClass: TClass; override; + // Properties + property DelphiObject: TCustomMultiView read GetDelphiObject write SetDelphiObject; + end; + + TPyDelphiMultiView = class(TPyDelphiCustomMultiView) + private + function GetDelphiObject: TMultiView; + procedure SetDelphiObject(const Value: TMultiView); + public + class function DelphiObjectClass: TClass; override; + // Properties + property DelphiObject: TMultiView read GetDelphiObject write SetDelphiObject; + end; + +implementation + +uses + WrapDelphi; + +{ Register the wrappers, the globals and the constants } +type + TComCtrlsRegistration = class(TRegisteredUnit) + public + function Name: string; override; + procedure RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper); override; + procedure DefineVars(APyDelphiWrapper: TPyDelphiWrapper); override; + end; + +{ TComCtrlsRegistration } + +procedure TComCtrlsRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper); +begin + inherited; +end; + +function TComCtrlsRegistration.Name: string; +begin + Result := 'ComCtrls'; +end; + +procedure TComCtrlsRegistration.RegisterWrappers( + APyDelphiWrapper: TPyDelphiWrapper); +begin + inherited; + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiTabControl); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomMultiView); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiMultiView); +end; + +{ TPyDelphiTabControl } + +class function TPyDelphiTabControl.DelphiObjectClass: TClass; +begin + Result := TTabControl; +end; + +function TPyDelphiTabControl.GetDelphiObject: TTabControl; +begin + Result := TTabControl(inherited DelphiObject); +end; + +procedure TPyDelphiTabControl.SetDelphiObject(const Value: TTabControl); +begin + inherited DelphiObject := Value; +end; + +{ TPyDelphiCustomMultiView } + +class function TPyDelphiCustomMultiView.DelphiObjectClass: TClass; +begin + Result := TCustomMultiView; +end; + +function TPyDelphiCustomMultiView.GetDelphiObject: TCustomMultiView; +begin + Result := TCustomMultiView(inherited DelphiObject); +end; + +procedure TPyDelphiCustomMultiView.SetDelphiObject( + const Value: TCustomMultiView); +begin + inherited DelphiObject := Value; +end; + +{ TPyDelphiMultiView } + +class function TPyDelphiMultiView.DelphiObjectClass: TClass; +begin + Result := TMultiView; +end; + +function TPyDelphiMultiView.GetDelphiObject: TMultiView; +begin + Result := TMultiView(inherited DelphiObject); +end; + +procedure TPyDelphiMultiView.SetDelphiObject(const Value: TMultiView); +begin + inherited DelphiObject := Value; +end; + +initialization + RegisteredUnits.Add( TComCtrlsRegistration.Create ); + +end. From 29a563ed2108cb8be3b94901275567ea4d3fdd65 Mon Sep 17 00:00:00 2001 From: Lucas Moura Belo Date: Mon, 21 Dec 2020 10:54:19 -0300 Subject: [PATCH 3/4] Adding TCustomMultiView wrapper --- Source/fmx/WrapFmxComCtrls.pas | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/Source/fmx/WrapFmxComCtrls.pas b/Source/fmx/WrapFmxComCtrls.pas index 21f98957..64cc023d 100644 --- a/Source/fmx/WrapFmxComCtrls.pas +++ b/Source/fmx/WrapFmxComCtrls.pas @@ -26,16 +26,6 @@ TPyDelphiCustomMultiView = class(TPyDelphiPresentedControl) property DelphiObject: TCustomMultiView read GetDelphiObject write SetDelphiObject; end; - TPyDelphiMultiView = class(TPyDelphiCustomMultiView) - private - function GetDelphiObject: TMultiView; - procedure SetDelphiObject(const Value: TMultiView); - public - class function DelphiObjectClass: TClass; override; - // Properties - property DelphiObject: TMultiView read GetDelphiObject write SetDelphiObject; - end; - implementation uses @@ -68,7 +58,6 @@ procedure TComCtrlsRegistration.RegisterWrappers( inherited; APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiTabControl); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomMultiView); - APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiMultiView); end; { TPyDelphiTabControl } @@ -88,7 +77,7 @@ procedure TPyDelphiTabControl.SetDelphiObject(const Value: TTabControl); inherited DelphiObject := Value; end; -{ TPyDelphiCustomMultiView } + { TPyDelphiCustomMultiView } class function TPyDelphiCustomMultiView.DelphiObjectClass: TClass; begin @@ -106,23 +95,6 @@ procedure TPyDelphiCustomMultiView.SetDelphiObject( inherited DelphiObject := Value; end; -{ TPyDelphiMultiView } - -class function TPyDelphiMultiView.DelphiObjectClass: TClass; -begin - Result := TMultiView; -end; - -function TPyDelphiMultiView.GetDelphiObject: TMultiView; -begin - Result := TMultiView(inherited DelphiObject); -end; - -procedure TPyDelphiMultiView.SetDelphiObject(const Value: TMultiView); -begin - inherited DelphiObject := Value; -end; - initialization RegisteredUnits.Add( TComCtrlsRegistration.Create ); From c5130baeb49cf5aa3f6be7bf09a50eafb4d7b82e Mon Sep 17 00:00:00 2001 From: Lucas Moura Belo Date: Mon, 21 Dec 2020 10:55:02 -0300 Subject: [PATCH 4/4] Adding TMultiView wrapper --- Source/fmx/WrapFmxComCtrls.pas | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Source/fmx/WrapFmxComCtrls.pas b/Source/fmx/WrapFmxComCtrls.pas index 64cc023d..56ef5497 100644 --- a/Source/fmx/WrapFmxComCtrls.pas +++ b/Source/fmx/WrapFmxComCtrls.pas @@ -26,6 +26,16 @@ TPyDelphiCustomMultiView = class(TPyDelphiPresentedControl) property DelphiObject: TCustomMultiView read GetDelphiObject write SetDelphiObject; end; + TPyDelphiMultiView = class(TPyDelphiCustomMultiView) + private + function GetDelphiObject: TMultiView; + procedure SetDelphiObject(const Value: TMultiView); + public + class function DelphiObjectClass: TClass; override; + // Properties + property DelphiObject: TMultiView read GetDelphiObject write SetDelphiObject; + end; + implementation uses @@ -58,6 +68,7 @@ procedure TComCtrlsRegistration.RegisterWrappers( inherited; APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiTabControl); APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomMultiView); + APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiMultiView); end; { TPyDelphiTabControl } @@ -95,6 +106,23 @@ procedure TPyDelphiCustomMultiView.SetDelphiObject( inherited DelphiObject := Value; end; +{ TPyDelphiMultiView } + +class function TPyDelphiMultiView.DelphiObjectClass: TClass; +begin + Result := TMultiView; +end; + +function TPyDelphiMultiView.GetDelphiObject: TMultiView; +begin + Result := TMultiView(inherited DelphiObject); +end; + +procedure TPyDelphiMultiView.SetDelphiObject(const Value: TMultiView); +begin + inherited DelphiObject := Value; +end; + initialization RegisteredUnits.Add( TComCtrlsRegistration.Create );