Skip to content

Pysamples #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Modules/DelphiFMX/DelphiFMX.dpr
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library DelphiFMX;

uses
System.StartUpCopy,
SysUtils,
Classes,
uMain in 'uMain.pas';
Expand Down
3 changes: 2 additions & 1 deletion Packages/Delphi/Delphi 10.4+/PythonFmx.dpk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 1 addition & 2 deletions Source/PythonEngine.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion Source/fmx/WrapDelphiFmx.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ implementation
WrapFmxScrollBox,
WrapFmxGrids,
WrapFmxMedia,
WrapFmxMenus;
WrapFmxMenus,
WrapFmxStyles;

end.
58 changes: 58 additions & 0 deletions Source/fmx/WrapFmxListBox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,6 +95,8 @@ procedure TListBoxRegistration.RegisterWrappers(
APyDelphiWrapper.RegisterDelphiWrapper(TPyListBoxItem);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomListBox);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiListBox);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomComboBox);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiComboBox);
end;

{ TPyListBoxItem }
Expand Down Expand Up @@ -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);

Expand Down
156 changes: 156 additions & 0 deletions Source/fmx/WrapFmxStyles.pas
Original file line number Diff line number Diff line change
@@ -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.
Loading