unit uPen;

interface

uses
{$IFDEF VCL}
  Graphics,
{$ELSE}
  QGraphics,
{$ENDIF}
  Rubies;

var
  cPen: Tvalue;

function ap_cPen: Tvalue;
function ap_iPen(real: TPen; owner: Tvalue): Tvalue;
procedure Init_Pen;

implementation

uses uIntern, uAlloc, uProp, uPhi;

function ap_cPen: Tvalue;
begin
  result := cPen;
end;

function Pen_alloc(klass: Tvalue; real: TPen): Tvalue;
begin
  result := TmpAlloc(klass, real);
end;

function ap_iPen(real: TPen; owner: Tvalue): Tvalue;
begin
  result := Pen_alloc(cPen, real);
  ap_owner(result, owner);
end;

function Pen_new(This: Tvalue): Tvalue; cdecl;
var
  real: TPen;
begin
  real := TPen.Create;
  result := ObjAlloc(This, real);

  ap_obj_call_init(result, 0, nil);
end;

procedure Init_Pen;
begin
  OutputConstSetType(mPhi, TypeInfo(TPenMode));
  OutputConstSetType(mPhi, TypeInfo(TPenStyle));

  cPen := rb_define_class_under(mPhi, 'Pen', ap_cObject);
  OutputProp(cPen, TPen);

  rb_define_singleton_method(cPen, 'new', @Pen_new, 0);
end;

end.
