X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/0d07716fe78436ae6c9c324cabdd401c25e336af..9c1598dfee450d4466a03e04e70d7a1601aba4ff:/gdk/gdk.lisp?ds=sidebyside diff --git a/gdk/gdk.lisp b/gdk/gdk.lisp index 54afe17..ce298c5 100644 --- a/gdk/gdk.lisp +++ b/gdk/gdk.lisp @@ -15,7 +15,7 @@ ;; 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: gdk.lisp,v 1.1 2000/08/14 16:44:39 espen Exp $ +;; $Id: gdk.lisp,v 1.3 2000/09/04 22:12:45 espen Exp $ (in-package "GDK") @@ -43,17 +43,17 @@ '%event-free) (deftype-method translate-from-alien - event (type-spec location &optional (alloc :dynamic)) + event (type-spec location &optional (alloc :reference)) `(let ((location ,location)) (unless (null-pointer-p location) (let ((event-class (find-event-class (funcall (get-reader-function 'event-type) location 0)))) ,(ecase alloc - (:dynamic '(ensure-alien-instance event-class location)) + (:copy '(ensure-alien-instance event-class location)) (:static '(ensure-alien-instance event-class location :static t)) - (:copy '(ensure-alien-instance - event-class (%event-copy location)))))))) + (:reference '(ensure-alien-instance + event-class (%event-copy location)))))))) (define-foreign event-poll-fd () int) @@ -367,13 +367,28 @@ ;;; Pixmaps +;; See the class definition for an explanation of this +(deftype-method alien-ref bitmap (type-spec) + (declare (ignore type-spec)) + '%drawable-ref) + +(deftype-method alien-unref bitmap (type-spec) + (declare (ignore type-spec)) + '%drawable-unref) + +(define-foreign %drawable-ref () pointer + (object (or bitmap pointer))) + +(define-foreign %drawable-unref () nil + (object (or bitmap pointer))) + + (define-foreign pixmap-new (width height depth &key window) pixmap (width int) (height int) (depth int) (window (or null window))) - (define-foreign %pixmap-colormap-create-from-xpm () pixmap (window (or null window)) (colormap (or null colormap)) @@ -381,31 +396,28 @@ (color (or null color)) (filename string)) -(define-foreign pixmap-colormap-create-from-xpm-d () pixmap +(define-foreign %pixmap-colormap-create-from-xpm-d () pixmap (window (or null window)) (colormap (or null colormap)) (mask bitmap :out) (color (or null color)) - (data pointer)) - -; (defun pixmap-create (source &key color window colormap) -; (let ((window -; (if (not (or window colormap)) -; (get-root-window) -; window))) -; (multiple-value-bind (pixmap bitmap) -; (typecase source -; ((or string pathname) -; (pixmap-colormap-create-from-xpm -; window colormap color (namestring (truename source)))) -; (t -; (with-array (data :initial-contents source :free-contents t) -; (pixmap-colormap-create-from-xpm-d window colormap color data)))) -; (if color -; (progn -; (bitmap-unref bitmap) -; pixmap) -; (values pixmap bitmap))))) + (data (vector string))) + +(defun pixmap-create (source &key color window colormap) + (let ((window + (if (not (or window colormap)) + (get-root-window) + window))) + (multiple-value-bind (pixmap mask) + (etypecase source + ((or string pathname) + (%pixmap-colormap-create-from-xpm + window colormap color (namestring (truename source)))) + ((vector string) + (%pixmap-colormap-create-from-xpm-d window colormap color source))) + (unreference-instance pixmap) + (unreference-instance mask) + (values pixmap mask))))