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

(require-library lolevel data-structures srfi-1 srfi-4 srfi-13)

(module canvas-draw-base
	(canvas? canvas->pointer pointer->canvas
	 context? context->pointer pointer->context
	 state? state->pointer pointer->state
	 context-capabilities
	 use-context+ make-canvas call-with-canvas
	 canvas-context
	 canvas-simulate!
	 canvas-attribute canvas-attribute-set!
	 canvas-state canvas-state-set!
	 canvas-clear! canvas-flush
	 canvas-size
	 canvas-mm->px canvas-px->mm
	 canvas-origin canvas-origin-set!
	 canvas-transform canvas-transform-set!
	 canvas-transform-compose!
	 canvas-transform-translate!
	 canvas-transform-scale!
	 canvas-transform-rotate!
	 canvas-foreground canvas-foreground-set!
	 canvas-background canvas-background-set!
	 canvas-write-mode canvas-write-mode-set!
	 canvas-clip-mode canvas-clip-mode-set!
	 canvas-clip-area canvas-clip-area-set!)
	(import
		scheme chicken foreign
		lolevel data-structures srfi-1 srfi-4 srfi-13)
	(include "canvas-draw-base.scm"))

(module canvas-draw-primitives
	(canvas-pixel!
	 canvas-mark!
	 canvas-mark-type canvas-mark-type-set!
	 canvas-mark-size canvas-mark-size-set!
	 canvas-line! canvas-rectangle! canvas-arc!
	 canvas-line-style canvas-line-style-set!
	 canvas-line-width canvas-line-width-set!
	 canvas-line-join canvas-line-join-set!
	 canvas-line-cap canvas-line-cap-set!
	 canvas-box! canvas-sector! canvas-chord!
	 canvas-background-opacity canvas-background-opacity-set!
	 canvas-fill-mode canvas-fill-mode-set!
	 canvas-interior-style canvas-interior-style-set!
	 canvas-text!
	 canvas-font canvas-font-set!
	 canvas-text-alignment canvas-text-alignment-set!
	 canvas-text-orientation canvas-text-orientation-set!
	 canvas-font-dimensions canvas-text-size canvas-text-box
	 call-with-canvas-in-mode canvas-path-set!
	 canvas-vertex!)
	(import scheme chicken foreign data-structures srfi-4 canvas-draw-base)
	(include "canvas-draw-primitives.scm"))

(module canvas-draw-play
	(canvas-play!)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-play.scm"))

(module canvas-draw-picture
	(context:picture)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-picture.scm"))

(module canvas-draw-client
	(context:image context:double-buffer
	 canvas-image/rgb canvas-image-put/rgb! canvas-image-put/rgba!)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-client.scm"))

(module canvas-draw-ps
	(context:ps)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-ps.scm"))

(module canvas-draw-svg
	(context:svg)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-svg.scm"))

(module canvas-draw-metafile
	(context:metafile)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-metafile.scm"))

(module canvas-draw-cgm
	(context:cgm)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-cgm.scm"))

(module canvas-draw-dgn
	(context:dgn)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-dgn.scm"))

(module canvas-draw-dxf
	(context:dxf)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-dxf.scm"))

(module canvas-draw-emf
	(context:emf)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-emf.scm"))

(module canvas-draw-wmf
	(context:wmf)
	(import scheme chicken foreign canvas-draw-base)
	(include "canvas-draw-wmf.scm"))

(cond-expand
 [disable-canvas-draw-iup]
 [else
	(module canvas-draw-iup
		(context:iup make-canvas-action make-cells-draw-cb)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-iup.scm"))])

(cond-expand
 [disable-canvas-draw-gl]
 [else
	(module canvas-draw-gl
		(context:gl)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-gl.scm"))])

(cond-expand
 [disable-canvas-draw-native]
 [else
	(module canvas-draw-native
		(context:native-window
		 screen-size)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-native.scm"))
	(module canvas-draw-server
		(context:image context:double-buffer)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-server.scm"))
	(module canvas-draw-clipboard
		(context:clipboard)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-clipboard.scm"))
	(module canvas-draw-printer
		(context:printer)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-printer.scm"))])

(cond-expand
 [disable-canvas-draw-pdf]
 [else
	(module canvas-draw-pdf
		(context:pdf)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-pdf.scm"))])

(cond-expand
 [enable-canvas-draw-debug
	(module canvas-draw-debug
		(context:debug)
		(import scheme chicken foreign canvas-draw-base)
		(include "canvas-draw-debug.scm"))]
 [else])

(module canvas-draw
	()
	(import scheme chicken)
	(reexport
		(except canvas-draw-base
		        canvas->pointer pointer->canvas
		        context->pointer pointer->context
		        state->pointer pointer->state)
		canvas-draw-primitives
		canvas-draw-play))
