| 1 | ;; Common Lisp bindings for GTK+ v2.0 |
| 2 | ;; Copyright (C) 2000 Espen S. Johnsen <esj@stud.cs.uit.no> |
| 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 | |
| 18 | ;; $Id: gparam.lisp,v 1.3 2001/05/11 16:06:02 espen Exp $ |
| 19 | |
| 20 | (in-package "GLIB") |
| 21 | |
| 22 | (deftype gvalue () 'pointer) |
| 23 | |
| 24 | (defconstant +gvalue-size+ (+ (size-of 'type-number) (* 4 (size-of 'double-float)))) |
| 25 | (defconstant +gvalue-value-offset+ (size-of 'type-number)) |
| 26 | |
| 27 | (defbinding (gvalue-init "g_value_init") () nil |
| 28 | (type type-number)) |
| 29 | |
| 30 | (defun gvalue-new (type) |
| 31 | (let ((gvalue (allocate-memory +gvalue-size+))) |
| 32 | (setf (system:sap-ref-32 gvalue 0) type) |
| 33 | ; (gvalue-init (type-number-of type)) |
| 34 | gvalue)) |
| 35 | |
| 36 | (defun gvalue-free (gvalue free-content) |
| 37 | (unless (null-pointer-p gvalue) |
| 38 | (when free-content |
| 39 | (funcall |
| 40 | (intern-destroy-function (gvalue-type gvalue)) |
| 41 | gvalue +gvalue-value-offset+)) |
| 42 | (deallocate-memory gvalue))) |
| 43 | |
| 44 | (defun gvalue-type (gvalue) |
| 45 | (type-from-number (system:sap-ref-32 gvalue 0))) |
| 46 | |
| 47 | (defun gvalue-get (gvalue) |
| 48 | (funcall |
| 49 | (intern-reader-function (gvalue-type gvalue)) |
| 50 | gvalue +gvalue-value-offset+)) |
| 51 | |
| 52 | (defun gvalue-set (gvalue value) |
| 53 | (funcall |
| 54 | (intern-writer-function (gvalue-type gvalue)) |
| 55 | value gvalue +gvalue-value-offset+) |
| 56 | value) |
| 57 | |
| 58 | |
| 59 | (deftype param-flag-type () |
| 60 | '(flags |
| 61 | (:readable 1) |
| 62 | (:writable 2) |
| 63 | (:construct 4) |
| 64 | (:construct-only 8) |
| 65 | (:lax-validation 16) |
| 66 | (:private 32))) |
| 67 | |
| 68 | (eval-when (:compile-toplevel :load-toplevel :execute) |
| 69 | (defclass param (ginstance) |
| 70 | ((name |
| 71 | :allocation :alien |
| 72 | :reader param-name |
| 73 | :type string) |
| 74 | (nickname |
| 75 | :allocation :alien |
| 76 | :reader param-nickname |
| 77 | :type string) |
| 78 | (documentation |
| 79 | :allocation :alien |
| 80 | :reader param-documentation |
| 81 | :type string) |
| 82 | (flags |
| 83 | :allocation :alien |
| 84 | :reader param-flags |
| 85 | :type param-flag-type) |
| 86 | (type |
| 87 | :allocation :alien |
| 88 | :reader param-type |
| 89 | :type type-number)) |
| 90 | (:metaclass ginstance-class) |
| 91 | (:ref "g_param_spec_ref") |
| 92 | (:unref "g_param_spec_unref"))) |
| 93 | |
| 94 | |
| 95 | (defclass param-char (param) |
| 96 | ((minimum |
| 97 | :allocation :alien |
| 98 | :reader param-char-minimum |
| 99 | :type char) |
| 100 | (maximum |
| 101 | :allocation :alien |
| 102 | :reader param-char-maximum |
| 103 | :type char) |
| 104 | (default-value |
| 105 | :allocation :alien |
| 106 | :reader param-char-default-value |
| 107 | :type char)) |
| 108 | (:metaclass ginstance-class)) |
| 109 | |
| 110 | (defclass param-unsigned-char (param) |
| 111 | ( |
| 112 | ; (minimum |
| 113 | ; :allocation :alien |
| 114 | ; :reader param-unsigned-char-minimum |
| 115 | ; :type unsigned-char) |
| 116 | ; (maximum |
| 117 | ; :allocation :alien |
| 118 | ; :reader param-unsigned-char-maximum |
| 119 | ; :type unsigned-char) |
| 120 | ; (default-value |
| 121 | ; :allocation :alien |
| 122 | ; :reader param-unsigned-char-default-value |
| 123 | ; :type unsigned-char) |
| 124 | ) |
| 125 | (:metaclass ginstance-class) |
| 126 | (:alien-name "GParamUChar")) |
| 127 | |
| 128 | (defclass param-boolean (param) |
| 129 | ((default-value |
| 130 | :allocation :alien |
| 131 | :reader param-boolean-default-value |
| 132 | :type boolean)) |
| 133 | (:metaclass ginstance-class)) |
| 134 | |
| 135 | (defclass param-int (param) |
| 136 | ((minimum |
| 137 | :allocation :alien |
| 138 | :reader param-int-minimum |
| 139 | :type int) |
| 140 | (maximum |
| 141 | :allocation :alien |
| 142 | :reader param-int-maximum |
| 143 | :type int) |
| 144 | (default-value |
| 145 | :allocation :alien |
| 146 | :reader param-int-default-value |
| 147 | :type int)) |
| 148 | (:metaclass ginstance-class)) |
| 149 | |
| 150 | (defclass param-unsigned-int (param) |
| 151 | ((minimum |
| 152 | :allocation :alien |
| 153 | :reader param-unsigned-int-minimum |
| 154 | :type unsigned-int) |
| 155 | (maximum |
| 156 | :allocation :alien |
| 157 | :reader param-unsigned-int-maximum |
| 158 | :type unsigned-int) |
| 159 | (default-value |
| 160 | :allocation :alien |
| 161 | :reader param-unsigned-int-default-value |
| 162 | :type unsigned-int)) |
| 163 | (:metaclass ginstance-class) |
| 164 | (:alien-name "GParamUInt")) |
| 165 | |
| 166 | (defclass param-long (param) |
| 167 | ((minimum |
| 168 | :allocation :alien |
| 169 | :reader param-long-minimum |
| 170 | :type long) |
| 171 | (maximum |
| 172 | :allocation :alien |
| 173 | :reader param-long-maximum |
| 174 | :type long) |
| 175 | (default-value |
| 176 | :allocation :alien |
| 177 | :reader param-long-default-value |
| 178 | :type long)) |
| 179 | (:metaclass ginstance-class)) |
| 180 | |
| 181 | (defclass param-unsigned-long (param) |
| 182 | ((minimum |
| 183 | :allocation :alien |
| 184 | :reader param-unsigned-long-minimum |
| 185 | :type unsigned-long) |
| 186 | (maximum |
| 187 | :allocation :alien |
| 188 | :reader param-unsigned-long-maximum |
| 189 | :type unsigned-long) |
| 190 | (default-value |
| 191 | :allocation :alien |
| 192 | :reader param-unsigned-long-default-value |
| 193 | :type unsigned-long)) |
| 194 | (:metaclass ginstance-class) |
| 195 | (:alien-name "GParamULong")) |
| 196 | |
| 197 | (defclass param-unichar (param) |
| 198 | () |
| 199 | (:metaclass ginstance-class)) |
| 200 | |
| 201 | (defclass param-enum (param) |
| 202 | ((class |
| 203 | :allocation :alien |
| 204 | :reader param-enum-class |
| 205 | :type pointer) |
| 206 | (default-value |
| 207 | :allocation :alien |
| 208 | :reader param-enum-default-value |
| 209 | :type long)) |
| 210 | (:metaclass ginstance-class)) |
| 211 | |
| 212 | (defclass param-flags (param) |
| 213 | ((class |
| 214 | :allocation :alien |
| 215 | :reader param-flags-class |
| 216 | :type pointer) |
| 217 | (default-value |
| 218 | :allocation :alien |
| 219 | :reader param-flags-default-value |
| 220 | :type long)) |
| 221 | (:metaclass ginstance-class)) |
| 222 | |
| 223 | (defclass param-single-float (param) |
| 224 | ((minimum |
| 225 | :allocation :alien |
| 226 | :reader param-single-float-minimum |
| 227 | :type single-float) |
| 228 | (maximum |
| 229 | :allocation :alien |
| 230 | :reader param-single-float-maximum |
| 231 | :type single-float) |
| 232 | (default-value |
| 233 | :allocation :alien |
| 234 | :reader param-single-float-default-value |
| 235 | :type single-float) |
| 236 | (epsilon |
| 237 | :allocation :alien |
| 238 | :reader param-single-float-epsilon |
| 239 | :type single-float)) |
| 240 | (:metaclass ginstance-class) |
| 241 | (:alien-name "GParamFloat")) |
| 242 | |
| 243 | (defclass param-double-float (param) |
| 244 | ((minimum |
| 245 | :allocation :alien |
| 246 | :reader param-double-float-minimum |
| 247 | :type double-float) |
| 248 | (maximum |
| 249 | :allocation :alien |
| 250 | :reader param-double-float-maximum |
| 251 | :type double-float) |
| 252 | (default-value |
| 253 | :allocation :alien |
| 254 | :reader param-double-float-default-value |
| 255 | :type double-float) |
| 256 | (epsilon |
| 257 | :allocation :alien |
| 258 | :reader param-double-float-epsilon |
| 259 | :type double-float)) |
| 260 | (:metaclass ginstance-class) |
| 261 | (:alien-name "GParamDouble")) |
| 262 | |
| 263 | (defclass param-string (param) |
| 264 | ((default-value |
| 265 | :allocation :alien |
| 266 | :reader param-string-default-value |
| 267 | :type string)) |
| 268 | (:metaclass ginstance-class)) |
| 269 | |
| 270 | (defclass param-param (param) |
| 271 | () |
| 272 | (:metaclass ginstance-class)) |
| 273 | |
| 274 | (defclass param-boxed (param) |
| 275 | () |
| 276 | (:metaclass ginstance-class)) |
| 277 | |
| 278 | (defclass param-pointer (param) |
| 279 | () |
| 280 | (:metaclass ginstance-class)) |
| 281 | |
| 282 | (defclass param-value-array (param) |
| 283 | ((element-spec |
| 284 | :allocation :alien |
| 285 | :reader param-value-array-element-spec |
| 286 | :type param) |
| 287 | (length |
| 288 | :allocation :alien |
| 289 | :reader param-value-array-length |
| 290 | :type unsigned-int)) |
| 291 | (:metaclass ginstance-class)) |
| 292 | |
| 293 | (defclass param-closure (param) |
| 294 | () |
| 295 | (:metaclass ginstance-class)) |
| 296 | |
| 297 | (defclass param-object (param) |
| 298 | () |
| 299 | (:metaclass ginstance-class)) |
| 300 | |
| 301 | |
| 302 | |