;; *** create or destroy regions *************************************

(import-lambda-definition-2 create-region () "scx_Create_Region")

(import-xlib-function set-region (display gc r)
  "scx_Set_Region")

(import-lambda-definition-2 destroy-region (r) "scx_Destroy_Region")

;; *** determine if regions are empty or equal ***********************

(import-lambda-definition-2 empty-region? (r) "scx_Empty_Region")

(import-lambda-definition-2 equal-region? (r1 r2) "scx_Equal_Region")

(import-lambda-definition-2 point-in-region? (r x y) "scx_Point_In_Region")

(define-enumerated-type rect-in-region-type :rect-in-region-type
  rect-in-region-type? rect-in-region-types rect-in-region-type-name
  rect-in-region-type-index
  (out in part))

(define-exported-binding "scx-rect-in-region-type" :rect-in-region-type)
(define-exported-binding "scx-rect-in-region-types" rect-in-region-types)

(import-lambda-definition-2 rect-in-region? (r x y w h) "scx_Rect_In_Region")

;; *** region arithmetic *********************************************

;; intersect-region! computes the intersection of SRA and SRB and
;; stores the result in the region DR.

(import-lambda-definition-2 intersect-region! (sra srb dr)
  "scx_Intersect_Region")

(define (intersect-region sra srb)
  (let ((dr (create-region)))
    (intersect-region! sra srb dr)
    dr))

(import-lambda-definition-2 union-region! (sra srb dr)
  "scx_Union_Region")

(define (union-region sra srb)
  (let ((dr (create-region)))
    (union-region! sra srb dr)
    dr))

(import-lambda-definition-2 union-rect-with-region! (x y w h src dest)
  "scx_Union_Rect_With_Region")

(define (union-rect-with-region x y w h src)
  (let ((dr (create-region)))
    (union-rect-with-region! x y w h src dr)
    dr))

(import-lambda-definition-2 subtract-region! (sra srb dr)
  "scx_Subtract_Region")

(define (subtract-region sra srb)
  (let ((dr (create-region)))
    (subtract-region! sra srb dr)
    dr))

(import-lambda-definition-2 xor-region! (sra srb dr)
  "scx_Xor_Region")

(define (xor-region sra srb)
  (let ((dr (create-region)))
    (xor-region! sra srb dr)
    dr))

(import-lambda-definition-2 offset-region! (r dx dy)
  "scx_Offset_Region")

(import-lambda-definition-2 shrink-region! (r dx dy)
  "scx_Shrink_Region")

;; *** generate regions **********************************************

;; points has to be a list of pairs (x . y).

(import-lambda-definition-2 polygon-region (points fill-rule)
  "scx_Polygon_Region")

;; clip-box returns a list (x y width height)

(import-lambda-definition-2 clip-box (r)
  "scx_Clip_Box")
