File canvas-draw/canvas-draw-iup.scm artifact 5df2a61079 part of check-in b465d05d14


;; -*- mode: Scheme; tab-width: 2; -*- ;;

;; {{{ Data types

(foreign-declare
	"#include <cd.h>\n"
	"#include <cdiup.h>\n")

(include "canvas-draw-types.scm")

;; }}}

;; {{{ Context types

(define context:iup
	(foreign-value "CD_IUP" nonnull-context))

;; }}}

;; {{{ Auxiliary functions

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

(define (make-cells-draw-cb proc)
	(let ([wrap (pointer->canvas #t)])
		(lambda (handle i j x-min x-max y-min y-max canvas)
			(call-with-canvas (wrap canvas) (cut proc handle i j x-min x-max y-min y-max <>)))))

;; }}}