uses
  objects,
  iodrv,
  controls,
  grctrls,
  PCDrv,
  PCMCus,
  fonts,
  Foss16;

var
  R  : TRect;
  ap : PApplication;
  pg : PPage;
  st : PStaticText;
  bt : PButton;

procedure skrtni( AControl: PControl; ACanvas: PCanvas ); far;
var
  r : TRect;
begin
  AControl^.GetExtent( R );
  with ACanvas^ do
  begin
    pen.color := clBlack;
    pen.style := psSolid;
    DrawLine( r.a.x, r.a.y, r.b.x, r.b.y);
    DrawLine( r.a.x, r.b.y, r.b.x, r.a.y);
  end;
end;

begin
  ap := new( PApplication, init(
          new( PInputDriver, init(
            new( PPCKeybDriver, init ),
            new( PPCMouseDriver, init )
          )),
          new( PVgaMonoDriver, init( 640, 480 )),
          nil
        ));
  ap^.Customize( ccApplication );
  ap^.SetFont( fidSS16 );

    R.Assign( 0, 0, 320, 240 );
    pg := new( PPage, Init( R ));
    pg^.Customize( ccPage );

      R.Assign( 1, 1, 319, 18 );
      st := new( PStaticText , init( R, 'Ahoj' ));
      st^.Customize( ccStaticText );
      st^.SetFlags( stfBorder, 0 );
      pg^.Insert( st );

      R.Assign( 120, 100, 200, 120 );
      bt := new( PButton, init( R, 'Stiskni', 0, 0 ));
      bt^.Customize( ccButton );
      bt^.AfterPaint := skrtni;
      pg^.Insert( bt );

    ap^.Insert( pg );

  ap^.Run;
  dispose( ap, done );
end.