1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 2000-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: gtkwidget.lisp,v 1.4 2001/05/29 15:58:24 espen Exp $
23 (defmethod initialize-instance ((widget widget) &rest initargs &key parent)
24 (declare (ignore initargs))
28 (with-slots ((container parent) child-slots) widget
30 container (car parent)
34 (slot-value (class-of container) 'child-class)
35 :parent container :child widget (cdr parent)))))
37 (setf (slot-value widget 'parent) parent))))
40 (defmethod slot-unbound ((class gobject) (object widget) slot)
42 ((and (eq slot 'child-slots) (slot-value object 'parent))
43 (with-slots (parent child-slots) object
47 (gethash (class-of parent) *container-to-child-class-mappings*)
48 :parent parent :child object))))
49 (t (call-next-method))))
52 (defun child-slot-value (widget slot)
53 (slot-value (widget-child-slots widget) slot))
55 (defun (setf child-slot-value) (value widget slot)
56 (setf (slot-value (widget-child-slots widget) slot) value))
58 (defmacro with-child-slots (slots widget &body body)
59 `(with-slots ,slots (widget-child-slots ,widget)
62 (defmacro widget-destroyed (place)
65 (defbinding widget-destroy () nil
68 (defbinding widget-unparent () nil
71 (defbinding widget-show () nil
74 (defbinding widget-show-now () nil
77 (defbinding widget-hide () nil
80 (defbinding widget-show-all () nil
83 (defbinding widget-hide-all () nil
86 (defbinding widget-map () nil
89 (defbinding widget-unmap () nil
92 (defbinding widget-realize () nil
95 (defbinding widget-unrealize () nil
98 (defbinding widget-add-accelerator
99 (widget signal accel-group key modifiers flags) nil
101 ((name-to-string signal) string)
102 (accel-group accel-group)
103 ((gdk:keyval-from-name key) unsigned-int)
104 (modifiers gdk:modifier-type)
107 (defbinding widget-remove-accelerator
108 (widget accel-group key modifiers) nil
110 (accel-group accel-group)
111 ((gdk:keyval-from-name key) unsigned-int)
112 (modifiers gdk:modifier-type))
114 (defbinding widget-accelerator-signal
115 (widget accel-group key modifiers) unsigned-int
117 (accel-group accel-group)
118 ((gdk:keyval-from-name key) unsigned-int)
119 (modifiers gdk:modifier-type))
121 (defbinding widget-lock-accelerators () nil
124 (defbinding widget-unlock-accelerators () nil
127 (defbinding (widget-accelerators-locked-p "gtk_widget_accelerators_locked")
131 (defbinding widget-event () int
135 (defbinding get-event-widget () widget
138 (defbinding widget-activate () boolean
141 (defbinding widget-set-scroll-adjustments () boolean
143 (hadjustment adjustment)
144 (vadjustment adjustment))
146 (defbinding widget-reparent () nil
150 ; (defbinding widget-popup () nil
155 (defbinding widget-grab-focus () nil
158 (defbinding widget-grab-default () nil
161 (defbinding grab-add () nil
164 (defbinding grab-get-current () widget)
166 (defbinding grab-remove () nil
169 (defbinding widget-allocation () nil
175 (defbinding widget-set-uposition (widget &key (x t) (y t)) nil
186 (defbinding widget-add-events () nil
188 (events gdk:event-mask))
190 (defbinding (widget-toplevel "gtk_widget_get_toplevel") () widget
193 (defbinding (widget-ancestor "gtk_widget_get_ancestor") (widget type) widget
195 ((find-type-number type) type-number))
197 ; (defbinding ("gtk_widget_get_colormap" widget-colormap) () gdk:colormap
200 ; (defbinding ("gtk_widget_get_visual" widget-visual) () gdk:visual
203 (defbinding (widget-pointer "gtk_widget_get_pointer") () nil
208 (defbinding (widget-is-ancestor-p "gtk_widget_is_ancestor") () boolean
212 (defbinding widget-set-rc-style () nil
215 (defbinding widget-ensure-style () nil
218 (defbinding widget-restore-default-style () nil
221 (defbinding widget-reset-rc-styles () nil
224 (defun (setf widget-cursor) (cursor-type widget)
225 (let ((cursor (gdk:cursor-new cursor-type))
226 (window (widget-window widget)))
227 (gdk:window-set-cursor window cursor)
228 ;(gdk:cursor-destroy cursor)
231 ;; Push/pop pairs, to change default values upon a widget's creation.
232 ;; This will override the values that got set by the
233 ;; widget-set-default-* functions.
235 (defbinding widget-push-style () nil
238 (defbinding widget-push-colormap () nil
239 (colormap gdk:colormap))
241 ; (defbinding widget-push-visual () nil
242 ; (visual gdk:visual))
244 (defbinding widget-push-composite-child () nil)
246 (defbinding widget-pop-style () nil)
248 (defbinding widget-pop-colormap () nil)
250 ;(defbinding widget-pop-visual () nil)
252 (defbinding widget-pop-composite-child () nil)
255 ;; Set certain default values to be used at widget creation time.
257 (defbinding widget-set-default-style () nil
260 (defbinding widget-set-default-colormap () nil
261 (colormap gdk:colormap))
263 ; (defbinding widget-set-default-visual () nil
264 ; (visual gdk:visual))
266 (defbinding widget-get-default-style () style)
268 (defbinding widget-get-default-colormap () gdk:colormap)
270 (defbinding widget-get-default-visual () gdk:visual)
272 (defbinding widget-shape-combine-mask () nil
274 (shape-mask gdk:bitmap)
278 ;; defined in gtkglue.c
279 (defbinding widget-mapped-p () boolean