2001-06-25 07:46:06 -04:00
|
|
|
;; ...
|
|
|
|
|
|
|
|
(define (create-gcontext . args)
|
|
|
|
(let ((alist (named-args->alist args)))
|
2001-07-16 09:23:39 -04:00
|
|
|
(receive (drawable rest) (alist-split alist '((drawable . #f)))
|
2001-06-25 07:46:06 -04:00
|
|
|
(let* ((rest (map cons
|
|
|
|
(map car rest)
|
|
|
|
(map (lambda (obj)
|
|
|
|
(cond
|
|
|
|
((pixel? obj) (pixel-Xpixel obj))
|
|
|
|
((font? obj) (font-Xfont obj))
|
|
|
|
((pixmap? obj) (pixmap-Xpixmap obj))
|
|
|
|
(else obj)))
|
|
|
|
(map cdr rest))))
|
|
|
|
(display (drawable-display drawable))
|
|
|
|
(Xdisplay (display-Xdisplay display))
|
|
|
|
(Xobject (drawable-Xobject drawable)))
|
|
|
|
(let ((Xgcontext (%create-gcontext Xdisplay Xobject rest)))
|
2001-07-19 11:19:07 -04:00
|
|
|
(make-gcontext Xgcontext display #t))))))
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
(import-lambda-definition %create-gcontext (Xdisplay Xdrawable alist)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Create_Gc")
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
;; ...
|
|
|
|
|
|
|
|
(define (copy-gcontext gcontext drawable)
|
|
|
|
(let* ((new-gcontext (create-gcontext 'drawable drawable))
|
|
|
|
(new-Xgcontext (gcontext-Xgcontext new-gcontext))
|
|
|
|
(Xgcontext (gcontext-Xgcontext gcontext))
|
2001-07-09 09:49:38 -04:00
|
|
|
(Xdisplay (display-Xdisplay (gcontext-display gcontext))))
|
|
|
|
(%copy-gcontext Xdisplay Xgcontext new-Xgcontext)
|
2001-06-25 07:46:06 -04:00
|
|
|
new-gcontext))
|
|
|
|
|
|
|
|
(import-lambda-definition %copy-gcontext (Xdisplay Xsource Xdest)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Copy_Gc")
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
;; ...
|
|
|
|
|
|
|
|
(define (get-gcontext-values gcontext)
|
|
|
|
(let ((Xgcontext (gcontext-Xgcontext gcontext))
|
|
|
|
(Xdisplay (display-Xdisplay (gcontext-display gcontext))))
|
2001-07-09 09:49:38 -04:00
|
|
|
(let ((vals (%get-gcontext-values Xgcontext Xdisplay)))
|
|
|
|
(if (not vals)
|
2001-06-25 07:46:06 -04:00
|
|
|
(error "cannot get gcontext values." gcontext)
|
|
|
|
(let*
|
2001-07-09 09:49:38 -04:00
|
|
|
((mod-vals (begin
|
|
|
|
(vector-set! vals 1 ;; plane-mask
|
|
|
|
(make-pixel (vector-ref vals 1)))
|
|
|
|
(vector-set! vals 2 ;; foreground
|
|
|
|
(make-pixel (vector-ref vals 2)))
|
|
|
|
(vector-set! vals 3 ;; background
|
|
|
|
(make-pixel (vector-ref vals 3)))
|
|
|
|
;; TODO: tile, stipple, font ...??
|
|
|
|
vals))
|
|
|
|
(alist
|
|
|
|
(map cons
|
|
|
|
'(function plane-mask foreground background
|
|
|
|
line-width line-style cap-style join-style
|
|
|
|
fill-style fill-rule arc-mode tile stipple ts-x ts-y
|
|
|
|
font subwindow-mode exposures clip-x clip-y
|
|
|
|
clip-mask dash-offset dashes)
|
|
|
|
(vector->list mod-vals))))
|
|
|
|
alist)))))
|
|
|
|
|
|
|
|
(import-lambda-definition %get-gcontext-values (Xgcontext Xdisplay)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Get_Gc_Values")
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
;;...
|
|
|
|
|
|
|
|
(define (make-gcontext-getter name)
|
|
|
|
(lambda (gcontext)
|
|
|
|
(cdr (assq name (get-gcontext-values gcontext)))))
|
|
|
|
|
|
|
|
(define gcontext-function (make-gcontext-getter 'function))
|
|
|
|
(define gcontext-plane-mask (make-gcontext-getter 'plane-mask))
|
|
|
|
(define gcontext-foreground (make-gcontext-getter 'foreground))
|
|
|
|
(define gcontext-background (make-gcontext-getter 'background))
|
|
|
|
(define gcontext-line-width (make-gcontext-getter 'line-width))
|
|
|
|
(define gcontext-line-style (make-gcontext-getter 'line-style))
|
|
|
|
(define gcontext-cap-style (make-gcontext-getter 'cap-style))
|
|
|
|
(define gcontext-join-style (make-gcontext-getter 'join-style))
|
|
|
|
(define gcontext-fill-style (make-gcontext-getter 'fill-style))
|
2001-07-09 09:49:38 -04:00
|
|
|
(define gcontext-fill-rule (make-gcontext-getter 'fill-rule))
|
2001-06-25 07:46:06 -04:00
|
|
|
(define gcontext-arc-mode (make-gcontext-getter 'arc-mode))
|
|
|
|
(define gcontext-tile (make-gcontext-getter 'tile))
|
|
|
|
(define gcontext-stipple (make-gcontext-getter 'stipple))
|
|
|
|
(define gcontext-ts-x (make-gcontext-getter 'ts-x))
|
|
|
|
(define gcontext-ts-y (make-gcontext-getter 'ts-y))
|
|
|
|
(define gcontext-font (make-gcontext-getter 'font))
|
|
|
|
(define gcontext-subwindow-mode (make-gcontext-getter 'subwindow-mode))
|
|
|
|
(define gcontext-exposures (make-gcontext-getter 'exposures))
|
|
|
|
(define gcontext-clip-x (make-gcontext-getter 'clip-x))
|
|
|
|
(define gcontext-clip-y (make-gcontext-getter 'clip-y))
|
|
|
|
(define gcontext-clip-mask (make-gcontext-getter 'clip-mask))
|
|
|
|
(define gcontext-dash-offset (make-gcontext-getter 'dash-offset))
|
|
|
|
(define gcontext-dashes (make-gcontext-getter 'dashes))
|
|
|
|
|
|
|
|
;; ...
|
|
|
|
|
|
|
|
(define (change-gcontext gcontext . attrs)
|
|
|
|
(let* ((alist (named-args->alist attrs))
|
|
|
|
(prep-alist
|
|
|
|
(map cons
|
|
|
|
(map car alist)
|
|
|
|
(map (lambda (value)
|
|
|
|
(cond
|
|
|
|
((pixmap? value) (pixmap-Xpixmap value))
|
|
|
|
((font? value) (font-Xfont value)) ;;??
|
|
|
|
((pixel? value) (pixel-Xpixel value))
|
2001-07-30 10:43:22 -04:00
|
|
|
;; ??...
|
2001-06-25 07:46:06 -04:00
|
|
|
(else value)))
|
|
|
|
(map cdr alist)))))
|
|
|
|
(%change-gcontext (gcontext-Xgcontext gcontext)
|
|
|
|
(display-Xdisplay (gcontext-display gcontext))
|
|
|
|
prep-alist)))
|
|
|
|
|
|
|
|
|
2001-07-30 10:43:22 -04:00
|
|
|
(import-lambda-definition %change-gcontext (Xgcontext Xdisplay args)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Change_Gc")
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
(define (make-gcontext-setter name)
|
|
|
|
(lambda (gcontext value)
|
2001-07-16 09:23:39 -04:00
|
|
|
(change-gcontext gcontext (list (cons name value)))))
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
(define set-gcontext-function! (make-gcontext-setter 'function))
|
|
|
|
(define set-gcontext-plane-mask! (make-gcontext-setter 'plane-mask))
|
|
|
|
(define set-gcontext-foreground! (make-gcontext-setter 'foreground))
|
|
|
|
(define set-gcontext-background! (make-gcontext-setter 'background))
|
|
|
|
(define set-gcontext-line-width! (make-gcontext-setter 'line-width))
|
|
|
|
(define set-gcontext-line-style! (make-gcontext-setter 'line-style))
|
|
|
|
(define set-gcontext-cap-style! (make-gcontext-setter 'cap-style))
|
|
|
|
(define set-gcontext-join-style! (make-gcontext-setter 'join-style))
|
|
|
|
(define set-gcontext-fill-style! (make-gcontext-setter 'fill-style))
|
|
|
|
(define set-gcontext-fill-rule! (make-gcontext-setter 'fill-rule))
|
|
|
|
(define set-gcontext-arc-mode! (make-gcontext-setter 'arc-mode))
|
|
|
|
(define set-gcontext-tile! (make-gcontext-setter 'tile))
|
|
|
|
(define set-gcontext-stipple! (make-gcontext-setter 'stipple))
|
|
|
|
(define set-gcontext-ts-x! (make-gcontext-setter 'ts-x))
|
|
|
|
(define set-gcontext-ts-y! (make-gcontext-setter 'ts-y))
|
|
|
|
(define set-gcontext-font! (make-gcontext-setter 'font))
|
|
|
|
(define set-gcontext-subwindow-mode! (make-gcontext-setter 'subwindow-mode))
|
|
|
|
(define set-gcontext-exposures! (make-gcontext-setter 'exposures))
|
|
|
|
(define set-gcontext-clip-x! (make-gcontext-setter 'clip-x))
|
|
|
|
(define set-gcontext-clip-y! (make-gcontext-setter 'clip-y))
|
|
|
|
(define set-gcontext-clip-mask! (make-gcontext-setter 'clip-mask))
|
|
|
|
(define set-gcontext-dash-offset! (make-gcontext-setter 'dash-offset))
|
|
|
|
(define set-gcontext-dashes! (make-gcontext-setter 'dashes))
|
|
|
|
|
|
|
|
;; set-dashlist! is a more complex form of set-dashes!. (set-dashes! N) is
|
|
|
|
;; equivalent to (set-dash-list! .. #(N N))
|
|
|
|
|
|
|
|
(define (set-gcontext-dashlist! gcontext dash-offset dash-list)
|
|
|
|
(%set-dashlist (gcontext-Xgcontext gcontext)
|
|
|
|
(display-Xdisplay (gcontext-display gcontext))
|
|
|
|
dash-offset
|
|
|
|
dash-list))
|
|
|
|
|
2001-07-09 09:49:38 -04:00
|
|
|
(import-lambda-definition %set-dashlist (Xgcontext Xdisplay dashoffset dashlist)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Set_Gcontext_Dashlist")
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
;; ...
|
|
|
|
|
|
|
|
(define (set-gcontext-clip-rectangles! gcontext x y rectangles ordering)
|
2001-07-09 09:49:38 -04:00
|
|
|
(%set-gcontext-clip-rectangles! (gcontext-Xgcontext gcontext)
|
|
|
|
(display-Xdisplay (gcontext-display gcontext))
|
|
|
|
x y rectangles ordering))
|
|
|
|
|
|
|
|
(import-lambda-definition %set-gcontext-clip-rectangles! (Xgcontext Xdisplay x
|
|
|
|
y v ord)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Set_Gcontext_Clip_Rectangles")
|
2001-07-09 09:49:38 -04:00
|
|
|
|
|
|
|
;; ...
|
|
|
|
|
|
|
|
(define (query-best-size display width height shape)
|
|
|
|
(%query-best-size (display-Xdisplay display)
|
|
|
|
width height shape))
|
|
|
|
|
|
|
|
(import-lambda-definition %query-best-size (Xdisplay width height shape)
|
2001-07-31 10:54:53 -04:00
|
|
|
"scx_Query_Best_Size")
|
2001-07-09 09:49:38 -04:00
|
|
|
|
|
|
|
(define (query-best-cursor display width height)
|
|
|
|
(query-best-size display width height 'cursor))
|
|
|
|
|
|
|
|
(define (query-best-tile display width height)
|
|
|
|
(query-best-size display width height 'tile))
|
|
|
|
|
|
|
|
(define (query-best-stipple display width height)
|
|
|
|
(query-best-size display width height 'stipple))
|
|
|
|
|
2001-06-25 07:46:06 -04:00
|
|
|
|
|
|
|
|