chiark / gitweb /
Added with-gvalue macro
[clg] / gdk / gdkevents.lisp
index 9721c7aa5c7773c29f9800d3aaccae7fcf26e65f..7b0b6980ad8d1a093c1a8b1ffaaeee601f774072 100644 (file)
 ;; License along with this library; if not, write to the Free Software
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-;; $Id: gdkevents.lisp,v 1.1 2001-05-11 16:20:20 espen Exp $
+;; $Id: gdkevents.lisp,v 1.5 2004-11-06 21:39:58 espen Exp $
 
 (in-package "GDK")
 
 
 (defvar *event-classes* (make-hash-table))
 
-(defun %type-of-event (location)
-  (class-name
-   (gethash
-    (funcall (intern-reader-function 'event-type) location 0)
-    *event-classes*)))
-
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defclass event (boxed)
     ((%type
@@ -49,39 +43,35 @@   (defclass event (boxed)
 
 (defmethod initialize-instance ((event event) &rest initargs)
   (declare (ignore initargs))
-  (with-slots (location %type) event
-    (setf location (%event-new))
-    (setf %type (event-class-type (class-of event))))
-  (call-next-method))
-
-(deftype-method translate-from-alien
-    event (type-spec location &optional weak-ref)
-  (declare (ignore type-spec))    
-  `(let ((location ,location))
-     (unless (null-pointer-p location)
-       (ensure-proxy-instance (%type-of-event location) location ,weak-ref))))
-
-(defbinding %event-new () pointer)
+  (call-next-method)
+  (setf (slot-value event '%type) (event-class-type (class-of event))))
 
 
 ;;;; Metaclass for event classes
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
-  (defclass event-class (proxy-class)
-    ((event-type :reader event-class-type))))
+  (defclass event-class (boxed-class)
+    ((event-type :reader event-class-type)))
 
+  (defmethod validate-superclass ((class event-class) (super standard-class))
+    (subtypep (class-name super) 'event)))
 
-(defmethod shared-initialize ((class event-class) names
-                             &rest initargs &key type)
-  (declare (ignore initargs names))
+
+(defmethod shared-initialize ((class event-class) names &key name type)
   (call-next-method)
   (setf (slot-value class 'event-type) (first type))
-  (setf (gethash (first type) *event-classes*) class))
-
+  (setf (gethash (first type) *event-classes*) class)
+  (let ((class-name (or name (class-name class))))
+    (register-type class-name 'event)))
+  
+(let ((reader (reader-function 'event-type)))
+  (defun %event-class (location)
+    (gethash (funcall reader location 0) *event-classes*)))
 
-(defmethod validate-superclass
-  ((class event-class) (super pcl::standard-class))
-  (subtypep (class-name super) 'event))
+(defmethod ensure-proxy-instance ((class event-class) location)
+  (declare (ignore class))
+  (let ((class (%event-class location)))
+    (make-instance class :location location)))
 
 
 ;;;;
@@ -92,13 +82,14 @@ (defclass timed-event (event)
     :accessor event-time
     :initarg :time
     :type (unsigned 32)))
-  (:metaclass proxy-class))
+  (:metaclass event-class))
   
 (defclass delete-event (event)
   ()
   (:metaclass event-class)
   (:type :delete))
 
+
 (defclass destroy-event (event)
   ()
   (:metaclass event-class)