1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 2000-2001 Espen S. Johnsen <espen@users.sourceforge.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: gtkwidget.lisp,v 1.5 2001-10-21 23:22:04 espen Exp $
23 (defmethod initialize-instance ((widget widget) &rest initargs &key parent)
24 (declare (ignore initargs))
27 (let ((parent-widget (first (mklist parent)))
28 (args (rest (mklist parent))))
29 (apply #'container-add parent-widget widget args))))
31 (defmethod initialize-instance :after ((widget widget) &rest initargs
33 (declare (ignore initargs))
35 (widget-show-all widget)))
38 (defmethod slot-unbound ((class gobject-class) (object widget) slot)
40 ((and (eq slot 'child-slots) (slot-value object 'parent))
41 (with-slots (parent child-slots) object
45 (gethash (class-of parent) *container-to-child-class-mappings*)
46 :parent parent :child object))))
47 (t (call-next-method))))
50 (defun child-slot-value (widget slot)
51 (slot-value (widget-child-slots widget) slot))
53 (defun (setf child-slot-value) (value widget slot)
54 (setf (slot-value (widget-child-slots widget) slot) value))
56 (defmacro with-child-slots (slots widget &body body)
57 `(with-slots ,slots (widget-child-slots ,widget)
60 (defmacro widget-destroyed (place)
63 (defbinding widget-destroy () nil
66 (defbinding widget-unparent () nil
69 (defbinding widget-show () nil
72 (defbinding widget-show-now () nil
75 (defbinding widget-hide () nil
78 (defbinding widget-show-all () nil
81 (defbinding widget-hide-all () nil
84 (defbinding widget-map () nil
87 (defbinding widget-unmap () nil
90 (defbinding widget-realize () nil
93 (defbinding widget-unrealize () nil
96 (defbinding widget-add-accelerator
97 (widget signal accel-group key modifiers flags) nil
99 ((name-to-string signal) string)
100 (accel-group accel-group)
101 ((gdk:keyval-from-name key) unsigned-int)
102 (modifiers gdk:modifier-type)
105 (defbinding widget-remove-accelerator
106 (widget accel-group key modifiers) nil
108 (accel-group accel-group)
109 ((gdk:keyval-from-name key) unsigned-int)
110 (modifiers gdk:modifier-type))
112 (defbinding widget-accelerator-signal
113 (widget accel-group key modifiers) unsigned-int
115 (accel-group accel-group)
116 ((gdk:keyval-from-name key) unsigned-int)
117 (modifiers gdk:modifier-type))
119 (defbinding widget-lock-accelerators () nil
122 (defbinding widget-unlock-accelerators () nil
125 (defbinding (widget-accelerators-locked-p "gtk_widget_accelerators_locked")
129 (defbinding widget-event () int
133 (defbinding get-event-widget () widget
136 (defbinding widget-activate () boolean
139 (defbinding widget-set-scroll-adjustments () boolean
141 (hadjustment adjustment)
142 (vadjustment adjustment))
144 (defbinding widget-reparent () nil
148 ; (defbinding widget-popup () nil
153 (defbinding widget-grab-focus () nil
156 (defbinding widget-grab-default () nil
159 (defbinding grab-add () nil
162 (defbinding grab-get-current () widget)
164 (defbinding grab-remove () nil
167 (defbinding widget-allocation () nil
172 (defbinding widget-add-events () nil
174 (events gdk:event-mask))
176 (defbinding (widget-toplevel "gtk_widget_get_toplevel") () widget
179 (defbinding (widget-ancestor "gtk_widget_get_ancestor") (widget type) widget
181 ((find-type-number type) type-number))
183 (defbinding (widget-pointer "gtk_widget_get_pointer") () nil
188 (defbinding (widget-is-ancestor-p "gtk_widget_is_ancestor") () boolean
192 (defbinding widget-ensure-style () nil
195 (defbinding widget-reset-rc-styles () nil
198 (defun (setf widget-cursor) (cursor-type widget)
199 (let ((cursor (gdk:cursor-new cursor-type))
200 (window (widget-window widget)))
201 (gdk:window-set-cursor window cursor)
202 ;(gdk:cursor-destroy cursor)
205 ;; Push/pop pairs, to change default values upon a widget's creation.
206 ;; This will override the values that got set by the
207 ;; widget-set-default-* functions.
209 (defbinding widget-push-colormap () nil
210 (colormap gdk:colormap))
212 (defbinding widget-push-composite-child () nil)
214 (defbinding widget-pop-colormap () nil)
216 (defbinding widget-pop-composite-child () nil)
219 ;; Set certain default values to be used at widget creation time.
221 (defbinding widget-set-default-colormap () nil
222 (colormap gdk:colormap))
224 (defbinding widget-get-default-style () style)
226 (defbinding widget-get-default-colormap () gdk:colormap)
228 (defbinding widget-shape-combine-mask () nil
230 (shape-mask gdk:bitmap)
234 ;; defined in gtkglue.c
235 (defbinding widget-mapped-p () boolean