1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 1999-2001 Espen S. Johnsen <esj@stud.cs.uit.no>
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.9 2004/10/28 09:37:27 espen Exp $
26 (defbinding connection-number () int)
28 (defbinding (events-pending-p "gdk_events_pending") () boolean)
30 (defbinding event-get () event)
32 (defbinding event-peek () event)
34 (defbinding event-get-graphics-expose () event
37 (defbinding event-put () event
40 ;(defbinding event-handler-set () ...)
42 (defbinding set-show-events () nil
43 (show-events boolean))
47 (defbinding set-use-xshm () nil
50 (defbinding get-show-events () boolean)
52 (defbinding get-use-xshm () boolean)
54 (defbinding get-display () string)
56 ; (defbinding time-get () (unsigned 32))
58 ; (defbinding timer-get () (unsigned 32))
60 ; (defbinding timer-set () nil
61 ; (milliseconds (unsigned 32)))
63 ; (defbinding timer-enable () nil)
65 ; (defbinding timer-disable () nil)
69 (defbinding pointer-grab () int
71 (owner-events boolean)
72 (event-mask event-mask)
73 (confine-to (or null window))
74 (cursor (or null cursor))
77 (defbinding pointer-ungrab () nil
80 (defbinding keyboard-grab () int
82 (owner-events boolean)
85 (defbinding keyboard-ungrab () nil
88 (defbinding (pointer-is-grabbed-p "gdk_pointer_is_grabbed") () boolean)
90 (defbinding screen-width () int)
91 (defbinding screen-height () int)
93 (defbinding screen-width-mm () int)
94 (defbinding screen-height-mm () int)
96 (defbinding flush () nil)
97 (defbinding beep () nil)
103 (defbinding visual-get-best-depth () int)
105 (defbinding visual-get-best-type () visual-type)
107 (defbinding visual-get-system () visual)
110 (defbinding (%visual-get-best-with-nothing "gdk_visual_get_best") () visual)
112 (defbinding %visual-get-best-with-depth () visual
115 (defbinding %visual-get-best-with-type () visual
118 (defbinding %visual-get-best-with-both () visual
122 (defun visual-get-best (&key depth type)
124 ((and depth type) (%visual-get-best-with-both depth type))
125 (depth (%visual-get-best-with-depth depth))
126 (type (%visual-get-best-with-type type))
127 (t (%visual-get-best-with-nothing))))
129 ;(defbinding query-depths ..)
131 ;(defbinding query-visual-types ..)
133 (defbinding list-visuals () (glist visual))
138 ; (defbinding window-new ... )
140 (defbinding window-destroy () nil
144 ; (defbinding window-at-pointer () window
149 (defbinding window-show () nil
152 (defbinding window-hide () nil
155 (defbinding window-withdraw () nil
158 (defbinding window-move () nil
163 (defbinding window-resize () nil
168 (defbinding window-move-resize () nil
175 (defbinding window-reparent () nil
181 (defbinding window-clear () nil
185 '(window-clear-area-no-e window-clear-area-e))
187 (defbinding (window-clear-area-no-e "gdk_window_clear_area") () nil
189 (x int) (y int) (width int) (height int))
191 (defbinding window-clear-area-e () nil
193 (x int) (y int) (width int) (height int))
195 (defun window-clear-area (window x y width height &optional expose)
197 (window-clear-area-e window x y width height)
198 (window-clear-area-no-e window x y width height)))
200 ; (defbinding window-copy-area () nil
205 ; (source-window window)
211 (defbinding window-raise () nil
214 (defbinding window-lower () nil
217 ; (defbinding window-set-user-data () nil
219 (defbinding window-set-override-redirect () nil
221 (override-redirect boolean))
223 ; (defbinding window-add-filter () nil
225 ; (defbinding window-remove-filter () nil
227 (defbinding window-shape-combine-mask () nil
233 (defbinding window-set-child-shapes () nil
236 (defbinding window-merge-child-shapes () nil
239 (defbinding (window-is-visible-p "gdk_window_is_visible") () boolean
242 (defbinding (window-is-viewable-p "gdk_window_is_viewable") () boolean
245 (defbinding window-set-static-gravities () boolean
247 (use-static boolean))
249 ; (defbinding add-client-message-filter ...
256 (defbinding drag-status () nil
257 (context drag-context)
259 (time (unsigned 32)))
264 (defbinding window-set-cursor () nil
268 (defbinding window-get-pointer () window
272 (mask modifier-type :out))
274 (defbinding %get-default-root-window () window)
276 (defun get-root-window (&optional display)
278 (error "Not implemented")
279 (%get-default-root-window)))
284 (defbinding rgb-init () nil)
291 (deftype-method alien-ref cursor (type-spec)
292 (declare (ignore type-spec))
295 (deftype-method alien-unref cursor (type-spec)
296 (declare (ignore type-spec))
300 (defbinding cursor-new () cursor
301 (cursor-type cursor-type))
303 (defbinding cursor-new-from-pixmap () cursor
310 (defbinding %cursor-ref () pointer
311 (cursor (or cursor pointer)))
313 (defbinding %cursor-unref () nil
314 (cursor (or cursor pointer)))
320 (defbinding pixmap-new (width height depth &key window) pixmap
324 (window (or null window)))
326 (defbinding %pixmap-colormap-create-from-xpm () pixmap
327 (window (or null window))
328 (colormap (or null colormap))
330 (color (or null color))
333 (defbinding %pixmap-colormap-create-from-xpm-d () pixmap
334 (window (or null window))
335 (colormap (or null colormap))
337 (color (or null color))
338 (data (vector string)))
340 (defun pixmap-create (source &key color window colormap)
342 (if (not (or window colormap))
345 (multiple-value-bind (pixmap mask)
347 ((or string pathname)
348 (%pixmap-colormap-create-from-xpm
349 window colormap color (namestring (truename source))))
351 (%pixmap-colormap-create-from-xpm-d window colormap color source)))
352 ;; (unreference-instance pixmap)
353 ;; (unreference-instance mask)
354 (values pixmap mask))))
360 (defun %scale-value (value)
363 (float (truncate (* value 65535)))))
365 (defmethod initialize-instance ((color color) &rest initargs
367 (declare (ignore initargs))
369 (with-slots ((%red red) (%green green) (%blue blue)) color
371 %red (%scale-value red)
372 %green (%scale-value green)
373 %blue (%scale-value blue))))
375 (defun ensure-color (color)
381 'color :red (svref color 0) :green (svref color 1)
382 :blue (svref color 2)))))
386 ;;; Drawing functions
388 (defbinding draw-rectangle () nil
389 (drawable (or window pixmap bitmap))
390 (gc gc) (filled boolean)
391 (x int) (y int) (width int) (height int))
396 (defbinding keyval-name () string
397 (keyval unsigned-int))
399 (defbinding keyval-from-name () unsigned-int
402 (defbinding keyval-to-upper () unsigned-int
403 (keyval unsigned-int))
405 (defbinding keyval-to-lower ()unsigned-int
406 (keyval unsigned-int))
408 (defbinding (keyval-is-upper-p "gdk_keyval_is_upper") () boolean
409 (keyval unsigned-int))
411 (defbinding (keyval-is-lower-p "gdk_keyval_is_lower") () boolean
412 (keyval unsigned-int))