560af5c5 |
1 | ;; Common Lisp bindings for GTK+ v2.0 |
e5b416f0 |
2 | ;; Copyright (C) 2000-2001 Espen S. Johnsen <espen@users.sourceforge.net> |
560af5c5 |
3 | ;; |
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. |
8 | ;; |
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. |
13 | ;; |
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 |
17 | |
e5b416f0 |
18 | ;; $Id: gtkwidget.lisp,v 1.5 2001-10-21 23:22:04 espen Exp $ |
560af5c5 |
19 | |
20 | (in-package "GTK") |
21 | |
22 | |
560af5c5 |
23 | (defmethod initialize-instance ((widget widget) &rest initargs &key parent) |
24 | (declare (ignore initargs)) |
0d270bd9 |
25 | (call-next-method) |
e5b416f0 |
26 | (when parent |
27 | (let ((parent-widget (first (mklist parent))) |
28 | (args (rest (mklist parent)))) |
29 | (apply #'container-add parent-widget widget args)))) |
30 | |
31 | (defmethod initialize-instance :after ((widget widget) &rest initargs |
32 | &key show-all) |
33 | (declare (ignore initargs)) |
34 | (when show-all |
35 | (widget-show-all widget))) |
560af5c5 |
36 | |
37 | |
e5b416f0 |
38 | (defmethod slot-unbound ((class gobject-class) (object widget) slot) |
560af5c5 |
39 | (cond |
40 | ((and (eq slot 'child-slots) (slot-value object 'parent)) |
41 | (with-slots (parent child-slots) object |
42 | (setf |
43 | child-slots |
44 | (make-instance |
0d270bd9 |
45 | (gethash (class-of parent) *container-to-child-class-mappings*) |
560af5c5 |
46 | :parent parent :child object)))) |
47 | (t (call-next-method)))) |
48 | |
49 | |
50 | (defun child-slot-value (widget slot) |
51 | (slot-value (widget-child-slots widget) slot)) |
52 | |
53 | (defun (setf child-slot-value) (value widget slot) |
54 | (setf (slot-value (widget-child-slots widget) slot) value)) |
55 | |
56 | (defmacro with-child-slots (slots widget &body body) |
57 | `(with-slots ,slots (widget-child-slots ,widget) |
58 | ,@body)) |
59 | |
60 | (defmacro widget-destroyed (place) |
61 | `(setf ,place nil)) |
62 | |
0d270bd9 |
63 | (defbinding widget-destroy () nil |
560af5c5 |
64 | (widget widget)) |
65 | |
0d270bd9 |
66 | (defbinding widget-unparent () nil |
560af5c5 |
67 | (widget widget)) |
68 | |
0d270bd9 |
69 | (defbinding widget-show () nil |
560af5c5 |
70 | (widget widget)) |
71 | |
0d270bd9 |
72 | (defbinding widget-show-now () nil |
560af5c5 |
73 | (widget widget)) |
74 | |
0d270bd9 |
75 | (defbinding widget-hide () nil |
560af5c5 |
76 | (widget widget)) |
77 | |
0d270bd9 |
78 | (defbinding widget-show-all () nil |
560af5c5 |
79 | (widget widget)) |
80 | |
0d270bd9 |
81 | (defbinding widget-hide-all () nil |
560af5c5 |
82 | (widget widget)) |
83 | |
0d270bd9 |
84 | (defbinding widget-map () nil |
560af5c5 |
85 | (widget widget)) |
86 | |
0d270bd9 |
87 | (defbinding widget-unmap () nil |
560af5c5 |
88 | (widget widget)) |
89 | |
0d270bd9 |
90 | (defbinding widget-realize () nil |
560af5c5 |
91 | (widget widget)) |
92 | |
0d270bd9 |
93 | (defbinding widget-unrealize () nil |
560af5c5 |
94 | (widget widget)) |
95 | |
0d270bd9 |
96 | (defbinding widget-add-accelerator |
560af5c5 |
97 | (widget signal accel-group key modifiers flags) nil |
98 | (widget widget) |
99 | ((name-to-string signal) string) |
100 | (accel-group accel-group) |
101 | ((gdk:keyval-from-name key) unsigned-int) |
102 | (modifiers gdk:modifier-type) |
103 | (flags accel-flags)) |
104 | |
0d270bd9 |
105 | (defbinding widget-remove-accelerator |
560af5c5 |
106 | (widget accel-group key modifiers) nil |
107 | (widget widget) |
108 | (accel-group accel-group) |
109 | ((gdk:keyval-from-name key) unsigned-int) |
110 | (modifiers gdk:modifier-type)) |
111 | |
0d270bd9 |
112 | (defbinding widget-accelerator-signal |
560af5c5 |
113 | (widget accel-group key modifiers) unsigned-int |
114 | (widget widget) |
115 | (accel-group accel-group) |
116 | ((gdk:keyval-from-name key) unsigned-int) |
117 | (modifiers gdk:modifier-type)) |
118 | |
0d270bd9 |
119 | (defbinding widget-lock-accelerators () nil |
560af5c5 |
120 | (widget widget)) |
121 | |
0d270bd9 |
122 | (defbinding widget-unlock-accelerators () nil |
560af5c5 |
123 | (widget widget)) |
124 | |
0d270bd9 |
125 | (defbinding (widget-accelerators-locked-p "gtk_widget_accelerators_locked") |
126 | () boolean |
560af5c5 |
127 | (widget widget)) |
128 | |
0d270bd9 |
129 | (defbinding widget-event () int |
560af5c5 |
130 | (widget widget) |
131 | (event gdk:event)) |
132 | |
0d270bd9 |
133 | (defbinding get-event-widget () widget |
aace61f5 |
134 | (event gdk:event)) |
135 | |
0d270bd9 |
136 | (defbinding widget-activate () boolean |
560af5c5 |
137 | (widget widget)) |
138 | |
0d270bd9 |
139 | (defbinding widget-set-scroll-adjustments () boolean |
560af5c5 |
140 | (widget widget) |
141 | (hadjustment adjustment) |
142 | (vadjustment adjustment)) |
143 | |
0d270bd9 |
144 | (defbinding widget-reparent () nil |
560af5c5 |
145 | (widget widget) |
146 | (new-parent widget)) |
147 | |
0d270bd9 |
148 | ; (defbinding widget-popup () nil |
149 | ; (widget widget) |
150 | ; (x int) |
151 | ; (y int)) |
560af5c5 |
152 | |
0d270bd9 |
153 | (defbinding widget-grab-focus () nil |
560af5c5 |
154 | (widget widget)) |
155 | |
0d270bd9 |
156 | (defbinding widget-grab-default () nil |
560af5c5 |
157 | (widget widget)) |
158 | |
0d270bd9 |
159 | (defbinding grab-add () nil |
aace61f5 |
160 | (widget widget)) |
161 | |
0d270bd9 |
162 | (defbinding grab-get-current () widget) |
aace61f5 |
163 | |
0d270bd9 |
164 | (defbinding grab-remove () nil |
aace61f5 |
165 | (widget widget)) |
166 | |
0d270bd9 |
167 | (defbinding widget-allocation () nil |
560af5c5 |
168 | (widget widget) |
169 | (width int :out) |
170 | (height int :out)) |
171 | |
0d270bd9 |
172 | (defbinding widget-add-events () nil |
560af5c5 |
173 | (widget widget) |
174 | (events gdk:event-mask)) |
175 | |
0d270bd9 |
176 | (defbinding (widget-toplevel "gtk_widget_get_toplevel") () widget |
560af5c5 |
177 | (widget widget)) |
178 | |
0d270bd9 |
179 | (defbinding (widget-ancestor "gtk_widget_get_ancestor") (widget type) widget |
560af5c5 |
180 | (widget widget) |
181 | ((find-type-number type) type-number)) |
182 | |
0d270bd9 |
183 | (defbinding (widget-pointer "gtk_widget_get_pointer") () nil |
560af5c5 |
184 | (widget widget) |
185 | (x int :out) |
186 | (y int :out)) |
187 | |
0d270bd9 |
188 | (defbinding (widget-is-ancestor-p "gtk_widget_is_ancestor") () boolean |
560af5c5 |
189 | (widget widget) |
190 | (ancestor widget)) |
191 | |
0d270bd9 |
192 | (defbinding widget-ensure-style () nil |
560af5c5 |
193 | (widget widget)) |
194 | |
0d270bd9 |
195 | (defbinding widget-reset-rc-styles () nil |
560af5c5 |
196 | (widget widget)) |
197 | |
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) |
203 | )) |
204 | |
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. |
208 | |
0d270bd9 |
209 | (defbinding widget-push-colormap () nil |
560af5c5 |
210 | (colormap gdk:colormap)) |
211 | |
0d270bd9 |
212 | (defbinding widget-push-composite-child () nil) |
560af5c5 |
213 | |
0d270bd9 |
214 | (defbinding widget-pop-colormap () nil) |
560af5c5 |
215 | |
0d270bd9 |
216 | (defbinding widget-pop-composite-child () nil) |
560af5c5 |
217 | |
218 | |
219 | ;; Set certain default values to be used at widget creation time. |
220 | |
0d270bd9 |
221 | (defbinding widget-set-default-colormap () nil |
560af5c5 |
222 | (colormap gdk:colormap)) |
223 | |
0d270bd9 |
224 | (defbinding widget-get-default-style () style) |
560af5c5 |
225 | |
0d270bd9 |
226 | (defbinding widget-get-default-colormap () gdk:colormap) |
560af5c5 |
227 | |
0d270bd9 |
228 | (defbinding widget-shape-combine-mask () nil |
560af5c5 |
229 | (widget widget) |
230 | (shape-mask gdk:bitmap) |
231 | (x-offset int) |
232 | (y-offset int)) |
233 | |
aace61f5 |
234 | ;; defined in gtkglue.c |
0d270bd9 |
235 | (defbinding widget-mapped-p () boolean |
560af5c5 |
236 | (widget widget)) |
237 | |