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: gdkevents.lisp,v 1.2 2001/05/31 12:36:39 espen Exp $
23 (defvar *event-classes* (make-hash-table))
25 (defun %type-of-event (location)
28 (funcall (intern-reader-function 'event-type) location 0)
31 (eval-when (:compile-toplevel :load-toplevel :execute)
32 (defclass event (boxed)
38 :accessor event-window
43 :accessor event-send-event
46 (%align :allocation :alien :offset 2 :type (unsigned 8)))
47 (:metaclass boxed-class)))
50 (defmethod initialize-instance ((event event) &rest initargs)
51 (declare (ignore initargs))
52 (with-slots (location %type) event
53 (setf location (%event-new))
54 (setf %type (event-class-type (class-of event))))
57 (deftype-method translate-from-alien
58 event (type-spec location &optional weak-ref)
59 (declare (ignore type-spec))
60 `(let ((location ,location))
61 (unless (null-pointer-p location)
62 (ensure-proxy-instance (%type-of-event location) location ,weak-ref))))
64 (defbinding %event-new () pointer)
67 ;;;; Metaclass for event classes
69 (eval-when (:compile-toplevel :load-toplevel :execute)
70 (defclass event-class (proxy-class)
71 ((event-type :reader event-class-type)))
74 (defmethod shared-initialize ((class event-class) names
75 &rest initargs &key type)
76 (declare (ignore initargs names))
78 (setf (slot-value class 'event-type) (first type))
79 (setf (gethash (first type) *event-classes*) class))
82 (defmethod validate-superclass
83 ((class event-class) (super pcl::standard-class))
84 (subtypep (class-name super) 'event)))
89 (defclass timed-event (event)
95 (:metaclass proxy-class))
97 (defclass delete-event (event)
99 (:metaclass event-class)
102 (defclass destroy-event (event)
104 (:metaclass event-class)
107 (defclass expose-event (event)
120 :accessor event-width
125 :accessor event-height
130 :accessor event-count
133 (:metaclass event-class)
136 (defclass motion-notify-event (timed-event)
149 :offset #.(size-of 'pointer)
150 :accessor event-state
155 :accessor event-is-hint
157 :type (signed 16) ; should it be (boolean 16)?
162 :accessor event-device
167 :accessor event-root-x
172 :accessor event-root-y
175 (:metaclass event-class)
176 (:type :motion-notify))
178 (defclass button-press-event (timed-event)
191 :offset #.(size-of 'pointer)
192 :accessor event-state
197 :accessor event-button
202 :accessor event-device
207 :accessor event-root-x
212 :accessor event-root-y
215 (:metaclass event-class)
216 (:type :button-press))
218 (defclass 2-button-press-event (button-press-event)
220 (:metaclass event-class)
221 (:type :2button-press))
223 (defclass 3-button-press-event (button-press-event)
225 (:metaclass event-class)
226 (:type :3button-press))
228 (defclass button-release-event (button-press-event)
230 (:metaclass event-class)
231 (:type :button-release))
233 (defclass key-press-event (event)
235 (:metaclass event-class)
238 (defclass key-release-event (event)
240 (:metaclass event-class)
241 (:type :key-release))
243 (defclass enter-notify-event (event)
245 (:metaclass event-class)
246 (:type :enter-notify))
248 (defclass leave-notify-event (event)
250 (:metaclass event-class)
251 (:type :leave-notify))
253 (defclass focus-change-event (event)
255 (:metaclass event-class)
256 (:type :focus-change))
258 (defclass configure-event (event)
271 :accessor event-width
276 :accessor event-height
279 (:metaclass event-class)
282 (defclass map-event (event)
284 (:metaclass event-class)
287 (defclass unmap-event (event)
289 (:metaclass event-class)
292 (defclass property-notify-event (event)
294 (:metaclass event-class)
295 (:type :property-notify))
297 (defclass selection-clear-event (event)
299 (:metaclass event-class)
300 (:type :selection-clear))
302 (defclass selection-request-event (event)
304 (:metaclass event-class)
305 (:type :selection-request))
307 (defclass selection-notify-event (event)
309 (:metaclass event-class)
310 (:type :selection-notify))
312 (defclass drag-enter-event (event)
314 (:metaclass event-class)
317 (defclass drag-leave-event (event)
319 (:metaclass event-class)
322 (defclass drag-motion-event (event)
324 (:metaclass event-class)
325 (:type :drag-motion))
327 (defclass drag-status-event (event)
329 (:metaclass event-class)
330 (:type :drag-status))
332 (defclass drag-start-event (event)
334 (:metaclass event-class)
337 (defclass drag-finished-event (event)
339 (:metaclass event-class)
340 (:type :drag-finished))
342 (defclass client-event (event)
344 (:metaclass event-class)
345 ;(:type :client-event)
348 (defclass visibility-notify-event (event)
351 :accessor event-state
353 :type visibility-state))
354 (:metaclass event-class)
355 (:type :visibility-notify))
357 (defclass no-expose-event (event)
359 (:metaclass event-class)
362 (defclass scroll-event (timed-event)
364 (:metaclass event-class)
367 (defclass setting-event (timed-event)
369 (:metaclass event-class)