#include once "fltk-c.bi"

sub ButtonCB cdecl (wgt as Fl_Widget ptr, pData as any ptr)
  dim as integer w,h
  dim as Fl_Printer ptr prt = Fl_PrinterNew()
  if prt then
    Fl_PrinterStartJob prt,1
      Fl_PrinterStartPage prt
        Fl_PrinterSetCurrent prt
        Fl_PrinterGetPrintableRect prt,w,h
        print "page size " & w/72      & " x " & h/72      & " zoll"
        print "page size " & w/72*2.54 & " x " & h/72*2.54 & " cm"
        w \=16:w *=16
        h \=16:h *=16
        DrawRect 0,0,w-1,h-1
        for x as integer=0 to w-1 step 16
          DrawLine x,0,x,h-1
        next
        for y as integer=0 to h-1 step 16
          DrawLine 0,y,w-1,y
        next
      Fl_PrinterEndPage prt
    Fl_PrinterEndJob prt
    Fl_PrinterDelete prt
  end if
end sub


dim as Fl_Window ptr win = Fl_WindowNew(70,40)
dim as Fl_Button ptr btn = Fl_ButtonNew(10,10,60,20,"print")
Fl_WidgetSetCallBackArg btn,@ButtonCB

Fl_WindowShow win
Fl_Run


