Skip to content

Commit 68c3672

Browse files
committed
Extending/Fixing Graphic and Bitmap constructors
1 parent 94e247c commit 68c3672

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Source/vcl/WrapVclGraphics.pas

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ TPyDelphiGraphic = class(TPyDelphiPersistent)
3838
function Set_Transparent( AValue : PPyObject; AContext : Pointer) : integer; cdecl;
3939
function Set_Width( AValue : PPyObject; AContext : Pointer) : integer; cdecl;
4040
public
41+
constructor CreateWith(APythonType: TPythonType; args: PPyObject); override;
42+
4143
class function DelphiObjectClass : TClass; override;
4244
class procedure RegisterGetSets( PythonType : TPythonType ); override;
4345
class procedure RegisterMethods( PythonType : TPythonType ); override;
@@ -88,6 +90,8 @@ TPyDelphiBitmap = class(TPyDelphiGraphic)
8890
function Set_TransparentColor( AValue : PPyObject; AContext : Pointer) : Integer; cdecl;
8991
function Set_TransparentMode( AValue : PPyObject; AContext : Pointer) : Integer; cdecl;
9092
public
93+
constructor CreateWith(APythonType: TPythonType; args: PPyObject); override;
94+
9195
class function DelphiObjectClass : TClass; override;
9296
class procedure RegisterGetSets( PythonType : TPythonType ); override;
9397
class procedure RegisterMethods( PythonType : TPythonType ); override;
@@ -362,6 +366,13 @@ procedure TGraphicsRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrap
362366

363367
{ TPyDelphiGraphic }
364368

369+
constructor TPyDelphiGraphic.CreateWith(APythonType: TPythonType;
370+
args: PPyObject);
371+
begin
372+
inherited;
373+
DelphiObject := TGraphicClass(DelphiObjectClass()).Create();
374+
end;
375+
365376
class function TPyDelphiGraphic.DelphiObjectClass: TClass;
366377
begin
367378
Result := TGraphic;
@@ -695,6 +706,16 @@ function TPyDelphiGraphic.Set_Width(AValue: PPyObject;
695706

696707
{ TPyDelphiBitmap }
697708

709+
constructor TPyDelphiBitmap.CreateWith(APythonType: TPythonType;
710+
args: PPyObject);
711+
var
712+
LWidth, LHeight : Integer;
713+
begin
714+
inherited;
715+
if APythonType.Engine.PyArg_ParseTuple(args, 'ii:Create', @LWidth, @LHeight) <> 0 then
716+
DelphiObject.SetSize(LWidth, LHeight);
717+
end;
718+
698719
class function TPyDelphiBitmap.DelphiObjectClass: TClass;
699720
begin
700721
Result := TBitmap;

0 commit comments

Comments
 (0)