File canvas-draw/racket/iup.rkt artifact cde98249f5 part of check-in 8ca036fa3c


#lang racket
(require
 srfi/26
 ffi/unsafe
 "base.rkt")

(define libiup-cd
  (case (system-type 'os)
    [(windows)
     (ffi-lib "iupcd")]
    [else
     (ffi-lib "libiupcd")]))

;; {{{ Context types

(define context:iup
  ((get-ffi-obj "cdContextCGM" libiup-cd (_fun -> [context : _context]))))

(provide
 context:iup)

;; }}}

;; {{{ Auxiliary functions

(define (make-canvas-action proc)
  (let ([canvas #f])
    (λ (handle x y)
      (unless canvas (set! canvas (make-canvas context:iup handle)))
      (call-with-canvas canvas (cut proc <> x y)))))

(provide
 make-canvas-action)

;; }}}