Artifact cde98249f51821b0038afe248dc5c460101425c8:


#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)

;; }}}