1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 2000 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: gparam.lisp,v 1.9 2004/11/06 21:39:58 espen Exp $
22 (deftype gvalue () 'pointer)
24 (eval-when (:compile-toplevel :load-toplevel :execute)
25 (defbinding (size-of-gvalue "size_of_gvalue") () unsigned-int))
27 ;(defconstant +gvalue-size+ (+ (size-of 'type-number) (* 2 (size-of 'double-float))))
28 (defconstant +gvalue-size+ #.(size-of-gvalue))
30 (defconstant +gvalue-value-offset+ (size-of 'type-number))
32 (defbinding (%gvalue-init "g_value_init") () nil
36 (defbinding (gvalue-unset "g_value_unset") () nil
39 (defun gvalue-init (gvalue type &optional (value nil value-p))
40 (%gvalue-init gvalue (find-type-number type))
42 (funcall (writer-function type) value gvalue +gvalue-value-offset+)))
44 (defun gvalue-new (type &optional (value nil value-p))
45 (let ((gvalue (allocate-memory +gvalue-size+)))
47 (gvalue-init gvalue type value)
48 (gvalue-init gvalue type))
51 (defun gvalue-free (gvalue &optional (unset-p t))
52 (unless (null-pointer-p gvalue)
54 (gvalue-unset gvalue))
55 (deallocate-memory gvalue)))
57 (defun gvalue-type (gvalue)
58 (type-from-number (system:sap-ref-32 gvalue 0)))
60 (defun gvalue-get (gvalue)
61 (funcall (reader-function (gvalue-type gvalue))
62 gvalue +gvalue-value-offset+))
64 (defun gvalue-set (gvalue value)
65 (funcall (writer-function (gvalue-type gvalue))
66 value gvalue +gvalue-value-offset+)
71 (deftype param-flag-type ()
80 (eval-when (:compile-toplevel :load-toplevel :execute)
81 (defclass param-spec-class (ginstance-class)
84 (defmethod validate-superclass
85 ((class param-spec-class) (super pcl::standard-class))
86 t ;(subtypep (class-name super) 'param)
90 (defbinding %param-spec-ref () pointer
93 (defbinding %param-spec-unref () nil
96 (defmethod reference-foreign ((class param-spec-class) location)
97 (declare (ignore class))
98 (%param-spec-ref location))
100 (defmethod unreference-foreign ((class param-spec-class) location)
101 (declare (ignore class))
102 (%param-spec-unref location))
106 ;; TODO: rename to param-spec
107 (defclass param (ginstance)
115 :type param-flag-type)
118 :reader param-value-type
122 :reader param-owner-type
126 :getter "g_param_spec_get_nick"
127 :reader param-nickname
131 :getter "g_param_spec_get_blurb"
132 :reader param-documentation
134 (:metaclass param-spec-class))
137 (defclass param-char (param)
140 :reader param-char-minimum
144 :reader param-char-maximum
148 :reader param-char-default-value
150 (:metaclass param-spec-class))
152 (defclass param-unsigned-char (param)
156 ; :reader param-unsigned-char-minimum
157 ; :type unsigned-char)
160 ; :reader param-unsigned-char-maximum
161 ; :type unsigned-char)
164 ; :reader param-unsigned-char-default-value
165 ; :type unsigned-char)
167 (:metaclass param-spec-class)
168 (:alien-name "GParamUChar"))
170 (defclass param-boolean (param)
173 :reader param-boolean-default-value
175 (:metaclass param-spec-class))
177 (defclass param-int (param)
180 :reader param-int-minimum
184 :reader param-int-maximum
188 :reader param-int-default-value
190 (:metaclass param-spec-class))
192 (defclass param-unsigned-int (param)
195 :reader param-unsigned-int-minimum
199 :reader param-unsigned-int-maximum
203 :reader param-unsigned-int-default-value
205 (:metaclass param-spec-class)
206 (:alien-name "GParamUInt"))
208 (defclass param-long (param)
211 :reader param-long-minimum
215 :reader param-long-maximum
219 :reader param-long-default-value
221 (:metaclass param-spec-class))
223 (defclass param-unsigned-long (param)
226 :reader param-unsigned-long-minimum
230 :reader param-unsigned-long-maximum
234 :reader param-unsigned-long-default-value
235 :type unsigned-long))
236 (:metaclass param-spec-class)
237 (:alien-name "GParamULong"))
239 (defclass param-unichar (param)
241 (:metaclass param-spec-class))
243 (defclass param-enum (param)
246 :reader param-enum-class
250 :reader param-enum-default-value
252 (:metaclass param-spec-class))
254 (defclass param-flags (param)
257 :reader param-flags-class
261 :reader param-flags-default-value
263 (:metaclass param-spec-class))
265 (defclass param-single-float (param)
268 :reader param-single-float-minimum
272 :reader param-single-float-maximum
276 :reader param-single-float-default-value
280 :reader param-single-float-epsilon
282 (:metaclass param-spec-class)
283 (:alien-name "GParamFloat"))
285 (defclass param-double-float (param)
288 :reader param-double-float-minimum
292 :reader param-double-float-maximum
296 :reader param-double-float-default-value
300 :reader param-double-float-epsilon
302 (:metaclass param-spec-class)
303 (:alien-name "GParamDouble"))
305 (defclass param-string (param)
308 :reader param-string-default-value
310 (:metaclass param-spec-class))
312 (defclass param-param (param)
314 (:metaclass param-spec-class))
316 (defclass param-boxed (param)
318 (:metaclass param-spec-class))
320 (defclass param-pointer (param)
322 (:metaclass param-spec-class))
324 (defclass param-value-array (param)
327 :reader param-value-array-element-spec
331 :reader param-value-array-length
333 (:metaclass param-spec-class))
335 ;; (defclass param-closure (param)
337 ;; (:metaclass param-spec-class))
339 (defclass param-object (param)
341 (:metaclass param-spec-class))