1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 1999-2005 Espen S. Johnsen <espen@users.sf.net>
4 ;; This library is free software; you can redistribute it and/or
5 ;; modify it under the terms of the GNU Lesser General Public
6 ;; License as published by the Free Software Foundation; either
7 ;; version 2 of the License, or (at your option) any later version.
9 ;; This library is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;; Lesser General Public License for more details.
14 ;; You should have received a copy of the GNU Lesser General Public
15 ;; License along with this library; if not, write to the Free Software
16 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ;; $Id: gdk.lisp,v 1.16 2005-04-21 12:28:20 espen Exp $
25 (defbinding (gdk-init "gdk_parse_args") () nil
26 "Initializes the library without opening the display."
34 (defbinding %display-open () display
35 (display-name (or null string)))
37 (defun display-open (&optional display-name)
38 (let ((display (%display-open display-name)))
39 (unless (display-get-default)
40 (display-set-default display))
43 (defbinding %display-get-n-screens () int
46 (defbinding %display-get-screen () screen
50 (defun display-screens (&optional (display (display-get-default)))
52 for i from 0 below (%display-get-n-screens display)
53 collect (%display-get-screen display i)))
55 (defbinding display-get-default-screen
56 (&optional (display (display-get-default))) screen
59 (defbinding display-beep (&optional (display (display-get-default))) nil
62 (defbinding display-sync (&optional (display (display-get-default))) nil
65 (defbinding display-flush (&optional (display (display-get-default))) nil
68 (defbinding display-close (&optional (display (display-get-default))) nil
71 (defbinding display-get-event
72 (&optional (display (display-get-default))) event
75 (defbinding display-peek-event
76 (&optional (display (display-get-default))) event
79 (defbinding display-put-event
80 (event &optional (display (display-get-default))) event
84 (defbinding (display-connection-number "clg_gdk_connection_number")
85 (&optional (display (display-get-default))) int
92 (defbinding display-get-default () display)
94 (defbinding (display-manager "gdk_display_manager_get") () display-manager)
96 (defbinding (display-set-default "gdk_display_manager_set_default_display")
98 ((display-manager) display-manager)
105 (defbinding (events-pending-p "gdk_events_pending") () boolean)
107 (defbinding event-get () event)
109 (defbinding event-peek () event)
111 (defbinding event-get-graphics-expose () event
114 (defbinding event-put () event
117 ;(defbinding event-handler-set () ...)
119 (defbinding set-show-events () nil
120 (show-events boolean))
122 (defbinding get-show-events () boolean)
125 ;;; Miscellaneous functions
127 (defbinding screen-width () int)
128 (defbinding screen-height () int)
130 (defbinding screen-width-mm () int)
131 (defbinding screen-height-mm () int)
133 (defbinding pointer-grab
134 (window &key owner-events events confine-to cursor time) grab-status
136 (owner-events boolean)
138 (confine-to (or null window))
139 (cursor (or null cursor))
140 ((or time 0) (unsigned 32)))
142 (defbinding (pointer-ungrab "gdk_display_pointer_ungrab")
143 (&optional time (display (display-get-default))) nil
145 ((or time 0) (unsigned 32)))
147 (defbinding (pointer-is-grabbed-p "gdk_display_pointer_is_grabbed")
148 (&optional (display (display-get-default))) boolean)
150 (defbinding keyboard-grab (window &key owner-events time) grab-status
152 (owner-events boolean)
153 ((or time 0) (unsigned 32)))
155 (defbinding (keyboard-ungrab "gdk_display_keyboard_ungrab")
156 (&optional time (display (display-get-default))) nil
158 ((or time 0) (unsigned 32)))
162 (defbinding atom-intern (atom-name &optional only-if-exists) atom
163 ((string atom-name) string)
164 (only-if-exists boolean))
166 (defbinding atom-name () string
173 (defbinding visual-get-best-depth () int)
175 (defbinding visual-get-best-type () visual-type)
177 (defbinding visual-get-system () visual)
180 (defbinding (%visual-get-best-with-nothing "gdk_visual_get_best") () visual)
182 (defbinding %visual-get-best-with-depth () visual
185 (defbinding %visual-get-best-with-type () visual
188 (defbinding %visual-get-best-with-both () visual
192 (defun visual-get-best (&key depth type)
194 ((and depth type) (%visual-get-best-with-both depth type))
195 (depth (%visual-get-best-with-depth depth))
196 (type (%visual-get-best-with-type type))
197 (t (%visual-get-best-with-nothing))))
199 ;(defbinding query-depths ..)
201 ;(defbinding query-visual-types ..)
203 (defbinding list-visuals () (glist visual))
208 (defbinding window-destroy () nil
212 (defbinding window-at-pointer () window
216 (defbinding window-show () nil
219 (defbinding window-show-unraised () nil
222 (defbinding window-hide () nil
225 (defbinding window-is-visible-p () boolean
228 (defbinding window-is-viewable-p () boolean
231 (defbinding window-withdraw () nil
234 (defbinding window-iconify () nil
237 (defbinding window-deiconify () nil
240 (defbinding window-stick () nil
243 (defbinding window-unstick () nil
246 (defbinding window-maximize () nil
249 (defbinding window-unmaximize () nil
252 (defbinding window-fullscreen () nil
255 (defbinding window-unfullscreen () nil
258 (defbinding window-set-keep-above () nil
262 (defbinding window-set-keep-below () nil
266 (defbinding window-move () nil
271 (defbinding window-resize () nil
276 (defbinding window-move-resize () nil
283 (defbinding window-scroll () nil
288 (defbinding window-reparent () nil
294 (defbinding window-clear () nil
297 (defbinding %window-clear-area () nil
299 (x int) (y int) (width int) (height int))
301 (defbinding %window-clear-area-e () nil
303 (x int) (y int) (width int) (height int))
305 (defun window-clear-area (window x y width height &optional expose)
307 (%window-clear-area-e window x y width height)
308 (%window-clear-area window x y width height)))
310 (defbinding window-raise () nil
313 (defbinding window-lower () nil
316 (defbinding window-focus () nil
318 (timestamp unsigned-int))
320 (defbinding window-register-dnd () nil
323 (defbinding window-begin-resize-drag () nil
329 (timestamp unsigned-int))
331 (defbinding window-begin-move-drag () nil
336 (timestamp unsigned-int))
338 ;; komplett så langt
340 (defbinding window-set-user-data () nil
344 (defbinding window-set-override-redirect () nil
346 (override-redirect boolean))
348 ; (defbinding window-add-filter () nil
350 ; (defbinding window-remove-filter () nil
352 (defbinding window-shape-combine-mask () nil
358 (defbinding window-set-child-shapes () nil
361 (defbinding window-merge-child-shapes () nil
365 (defbinding window-set-static-gravities () boolean
367 (use-static boolean))
369 ; (defbinding add-client-message-filter ...
371 (defbinding window-set-cursor () nil
373 (cursor (or null cursor)))
375 (defbinding window-get-pointer () window
379 (mask modifier-type :out))
381 (defbinding %window-get-toplevels () (glist window))
383 (defun window-get-toplevels (&optional screen)
385 (error "Not implemented")
386 (%window-get-toplevels)))
388 (defbinding %get-default-root-window () window)
390 (defun get-root-window (&optional display)
392 (error "Not implemented")
393 (%get-default-root-window)))
401 (defbinding drag-status () nil
402 (context drag-context)
404 (time (unsigned 32)))
413 (defbinding rgb-init () nil)
420 (defmethod initialize-instance ((cursor cursor) &key type mask fg bg
421 (x 0) (y 0) (display (display-get-default)))
423 (slot-value cursor 'location)
425 (keyword (%cursor-new-for-display display type))
426 (pixbuf (%cursor-new-from-pixbuf display type x y))
427 (pixmap (%cursor-new-from-pixmap type mask fg bg x y)))))
430 (defbinding %cursor-new-for-display () pointer
432 (cursor-type cursor-type))
434 (defbinding %cursor-new-from-pixmap () pointer
441 (defbinding %cursor-new-from-pixbuf () pointer
446 (defbinding %cursor-ref () pointer
449 (defbinding %cursor-unref () nil
452 (defmethod reference-foreign ((class (eql (find-class 'cursor))) location)
453 (declare (ignore class))
454 (%cursor-ref location))
456 (defmethod unreference-foreign ((class (eql (find-class 'cursor))) location)
457 (declare (ignore class))
458 (%cursor-unref location))
463 (defbinding pixmap-new (width height depth &key window) pixmap
467 (window (or null window)))
469 (defbinding %pixmap-colormap-create-from-xpm () pixmap
470 (window (or null window))
471 (colormap (or null colormap))
473 (color (or null color))
476 (defbinding %pixmap-colormap-create-from-xpm-d () pixmap
477 (window (or null window))
478 (colormap (or null colormap))
480 (color (or null color))
481 (data (vector string)))
483 (defun pixmap-create (source &key color window colormap)
485 (if (not (or window colormap))
488 (multiple-value-bind (pixmap mask)
490 ((or string pathname)
491 (%pixmap-colormap-create-from-xpm
492 window colormap color (namestring (truename source))))
494 (%pixmap-colormap-create-from-xpm-d window colormap color source)))
495 ;; (unreference-instance pixmap)
496 ;; (unreference-instance mask)
497 (values pixmap mask))))
503 (defun %scale-value (value)
506 (float (truncate (* value 65535)))))
508 (defmethod initialize-instance ((color color) &rest initargs
510 (declare (ignore initargs))
512 (with-slots ((%red red) (%green green) (%blue blue)) color
514 %red (%scale-value red)
515 %green (%scale-value green)
516 %blue (%scale-value blue))))
518 (defun ensure-color (color)
524 'color :red (svref color 0) :green (svref color 1)
525 :blue (svref color 2)))))
531 (defbinding drawable-get-size () nil
536 (defbinding (drawable-width "gdk_drawable_get_size") () nil
541 (defbinding (drawable-height "gdk_drawable_get_size") () nil
546 ;; (defbinding drawable-get-clip-region () region
547 ;; (drawable drawable))
549 ;; (defbinding drawable-get-visible-region () region
550 ;; (drawable drawable))
552 (defbinding draw-point () nil
553 (drawable drawable) (gc gc)
556 (defbinding %draw-points () nil
557 (drawable drawable) (gc gc)
561 ;; (defun draw-points (drawable gc &rest points)
565 (defbinding draw-line () nil
566 (drawable drawable) (gc gc)
570 ;; (defbinding draw-lines (drawable gc &rest points) nil
571 ;; (drawable drawable) (gc gc)
572 ;; (points (vector point))
573 ;; ((length points) int))
575 (defbinding draw-pixbuf
576 (drawable gc pixbuf src-x src-y dest-x dest-y &optional
577 width height (dither :none) (x-dither 0) (y-dither 0)) nil
578 (drawable drawable) (gc (or null gc))
580 (src-x int) (src-y int)
581 (dest-x int) (dest-y int)
582 ((or width -1) int) ((or height -1) int)
584 (x-dither int) (y-dither int))
586 ;; (defbinding draw-segments (drawable gc &rest points) nil
587 ;; (drawable drawable) (gc gc)
588 ;; (segments (vector segments))
589 ;; ((length segments) int))
591 (defbinding draw-rectangle () nil
592 (drawable drawable) (gc gc)
595 (width int) (height int))
597 (defbinding draw-arc () nil
598 (drawable drawable) (gc gc)
601 (width int) (height int)
602 (angle1 int) (angle2 int))
604 ;; (defbinding draw-polygon (drawable gc &rest points) nil
605 ;; (drawable drawable) (gc gc)
606 ;; (points (vector point))
607 ;; ((length points) int))
609 ;; (defbinding draw-trapezoid (drawable gc &rest points) nil
610 ;; (drawable drawable) (gc gc)
611 ;; (points (vector point))
612 ;; ((length points) int))
614 ;; (defbinding %draw-layout-line () nil
615 ;; (drawable drawable) (gc gc)
618 ;; (line pango:layout-line))
620 ;; (defbinding %draw-layout-line-with-colors () nil
621 ;; (drawable drawable) (gc gc)
624 ;; (line pango:layout-line)
625 ;; (foreground (or null color))
626 ;; (background (or null color)))
628 ;; (defun draw-layout-line (drawable gc font x y line &optional foreground background)
629 ;; (if (or foreground background)
630 ;; (%draw-layout-line-with-colors drawable gc font x y line foreground background)
631 ;; (%draw-layout-line drawable gc font x y line)))
633 (defbinding %draw-layout () nil
634 (drawable drawable) (gc gc)
637 (layout pango:layout))
639 (defbinding %draw-layout-with-colors () nil
640 (drawable drawable) (gc gc)
643 (layout pango:layout)
644 (foreground (or null color))
645 (background (or null color)))
647 (defun draw-layout (drawable gc font x y layout &optional foreground background)
648 (if (or foreground background)
649 (%draw-layout-with-colors drawable gc font x y layout foreground background)
650 (%draw-layout drawable gc font x y layout)))
652 (defbinding draw-drawable
653 (drawable gc src src-x src-y dest-x dest-y &optional width height) nil
654 (drawable drawable) (gc gc)
656 (src-x int) (src-y int)
657 (dest-x int) (dest-y int)
658 ((or width -1) int) ((or height -1) int))
660 (defbinding draw-image
661 (drawable gc image src-x src-y dest-x dest-y &optional width height) nil
662 (drawable drawable) (gc gc)
664 (src-x int) (src-y int)
665 (dest-x int) (dest-y int)
666 ((or width -1) int) ((or height -1) int))
668 (defbinding drawable-get-image () image
671 (width int) (height int))
673 (defbinding drawable-copy-to-image
674 (drawable src-x src-y width height &optional image dest-x dest-y) image
676 (image (or null image))
677 (src-x int) (src-y int)
678 ((if image dest-x 0) int)
679 ((if image dest-y 0) int)
680 (width int) (height int))
685 (defbinding keyval-name () string
686 (keyval unsigned-int))
688 (defbinding keyval-from-name () unsigned-int
691 (defbinding keyval-to-upper () unsigned-int
692 (keyval unsigned-int))
694 (defbinding keyval-to-lower () unsigned-int
695 (keyval unsigned-int))
697 (defbinding (keyval-is-upper-p "gdk_keyval_is_upper") () boolean
698 (keyval unsigned-int))
700 (defbinding (keyval-is-lower-p "gdk_keyval_is_lower") () boolean
701 (keyval unsigned-int))