| 1 | ;; Common Lisp bindings for GTK+ v2.x |
| 2 | ;; Copyright 2000-2006 Espen S. Johnsen <espen@users.sf.net> |
| 3 | ;; |
| 4 | ;; Permission is hereby granted, free of charge, to any person obtaining |
| 5 | ;; a copy of this software and associated documentation files (the |
| 6 | ;; "Software"), to deal in the Software without restriction, including |
| 7 | ;; without limitation the rights to use, copy, modify, merge, publish, |
| 8 | ;; distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | ;; permit persons to whom the Software is furnished to do so, subject to |
| 10 | ;; the following conditions: |
| 11 | ;; |
| 12 | ;; The above copyright notice and this permission notice shall be |
| 13 | ;; included in all copies or substantial portions of the Software. |
| 14 | ;; |
| 15 | ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 18 | ;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 19 | ;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 20 | ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 21 | ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | |
| 23 | ;; $Id: gdktypes.lisp,v 1.27 2006-09-05 13:14:10 espen Exp $ |
| 24 | |
| 25 | (in-package "GDK") |
| 26 | |
| 27 | (eval-when (:compile-toplevel :load-toplevel :execute) |
| 28 | (init-types-in-library #.(concatenate 'string |
| 29 | (pkg-config:pkg-variable "gtk+-2.0" "libdir") |
| 30 | "/libgdk-x11-2.0." asdf:*dso-extension*) :prefix ("gdk_" "_gdk_")) |
| 31 | (init-types-in-library #.(concatenate 'string |
| 32 | (pkg-config:pkg-variable "gtk+-2.0" "libdir") |
| 33 | "/libgdk_pixbuf-2.0." asdf:*dso-extension*) :prefix "gdk_")) |
| 34 | |
| 35 | |
| 36 | (defclass color (boxed) |
| 37 | ((pixel |
| 38 | :allocation :alien |
| 39 | :type (unsigned 32)) |
| 40 | (red |
| 41 | :allocation :alien |
| 42 | :accessor color-red |
| 43 | :type (unsigned 16)) |
| 44 | (green |
| 45 | :allocation :alien |
| 46 | :accessor color-green |
| 47 | :type (unsigned 16)) |
| 48 | (blue |
| 49 | :allocation :alien |
| 50 | :accessor color-blue |
| 51 | :type (unsigned 16))) |
| 52 | (:metaclass boxed-class) |
| 53 | (:packed t)) |
| 54 | |
| 55 | |
| 56 | (deftype point () '(vector int 2)) |
| 57 | (deftype segment () '(vector int 4)) |
| 58 | (deftype trapezoid () '(vector double-float 6)) |
| 59 | (deftype atom () 'unsigned-int) |
| 60 | |
| 61 | |
| 62 | ;; Could this just as well have been a vector? |
| 63 | (defclass rectangle (boxed) |
| 64 | ((x |
| 65 | :allocation :alien |
| 66 | :accessor rectangle-x |
| 67 | :initarg :x |
| 68 | :type int) |
| 69 | (y |
| 70 | :allocation :alien |
| 71 | :accessor rectangle-y |
| 72 | :initarg :y |
| 73 | :type int) |
| 74 | (width |
| 75 | :allocation :alien |
| 76 | :accessor rectangle-width |
| 77 | :initarg :width |
| 78 | :type int) |
| 79 | (height |
| 80 | :allocation :alien |
| 81 | :accessor rectangle-height |
| 82 | :initarg :height |
| 83 | :type int)) |
| 84 | (:metaclass boxed-class)) |
| 85 | |
| 86 | (defclass region (struct) |
| 87 | () |
| 88 | (:metaclass struct-class) |
| 89 | (:ref %region-copy) |
| 90 | (:unref %region-destroy)) |
| 91 | |
| 92 | |
| 93 | (register-type 'event-mask '|gdk_event_mask_get_type|) |
| 94 | (define-flags-type event-mask |
| 95 | (:exposure 2) |
| 96 | :pointer-motion |
| 97 | :pointer-motion-hint |
| 98 | :button-motion |
| 99 | :button1-motion |
| 100 | :button2-motion |
| 101 | :button3-motion |
| 102 | :button-press |
| 103 | :button-release |
| 104 | :key-press |
| 105 | :key-release |
| 106 | :enter-notify |
| 107 | :leave-notify |
| 108 | :focus-change |
| 109 | :structure |
| 110 | :property-change |
| 111 | :visibility-notify |
| 112 | :proximity-in |
| 113 | :proximity-out |
| 114 | :substructure |
| 115 | :scroll |
| 116 | (:all-events #x3FFFFE)) |
| 117 | |
| 118 | (register-type 'modifier-type '|gdk_modifier_type_get_type|) |
| 119 | (define-flags-type modifier-type |
| 120 | :shift :lock :control :mod1 :mod2 :mod3 :mod4 :mod5 |
| 121 | :button1 :button2 :button3 :button4 :button5 |
| 122 | (:release #.(ash 1 30))) |
| 123 | |
| 124 | |
| 125 | (define-types-by-introspection "Gdk" |
| 126 | ("GdkFunction" :type gc-function) |
| 127 | ("GdkWMDecoration" :type wm-decoration) |
| 128 | ("GdkWMFunction" :type wm-function) |
| 129 | ("GdkGC" :type gc) |
| 130 | ("GdkGCX11" :type gc-x11) |
| 131 | ("GdkGCValuesMask" :type gc-values-mask) |
| 132 | ("GdkDrawableImplX11" :ignore t) |
| 133 | ("GdkWindowImplX11" :ignore t) |
| 134 | ("GdkPixmapImplX11" :ignore t) |
| 135 | ("GdkGCX11" :ignore t) |
| 136 | ("GdkColor" :ignore t) |
| 137 | ("GdkEvent" :ignore t) |
| 138 | ("GdkRectangle" :ignore t) |
| 139 | ("GdkCursor" :ignore t) |
| 140 | ("GdkFont" :ignore t) ; deprecated |
| 141 | ("GdkEventMask" :ignore t) ; manually defined |
| 142 | ("GdkModifierType" :ignore t) ; manually defined |
| 143 | |
| 144 | ("GdkDisplay" |
| 145 | :slots |
| 146 | ((name |
| 147 | :allocation :virtual |
| 148 | :getter "gdk_display_get_name" |
| 149 | :reader display-name |
| 150 | :type (copy-of string)) |
| 151 | (screens |
| 152 | :allocation :virtual |
| 153 | :getter display-screens) |
| 154 | (devices |
| 155 | :allocation :virtual |
| 156 | :getter "gdk_display_list_devices" |
| 157 | :reader display-devices |
| 158 | :type (copy-of (glist device))))) |
| 159 | |
| 160 | ("GdkDrawable" |
| 161 | :slots |
| 162 | ((display |
| 163 | :allocation :virtual |
| 164 | :getter "gdk_drawable_get_display" |
| 165 | :reader drawable-display |
| 166 | :type display) |
| 167 | (screen |
| 168 | :allocation :virtual |
| 169 | :getter "gdk_drawable_get_screen" |
| 170 | :reader drawable-screen |
| 171 | :type screen) |
| 172 | (visual |
| 173 | :allocation :virtual |
| 174 | :getter "gdk_drawable_get_visual" |
| 175 | :reader drawable-visual |
| 176 | :type visual) |
| 177 | (colormap |
| 178 | :allocation :virtual |
| 179 | :getter "gdk_drawable_get_colormap" |
| 180 | :setter "gdk_drawable_set_colormap" |
| 181 | :unbound nil |
| 182 | :accessor drawable-colormap |
| 183 | :initarg :colormap |
| 184 | :type colormap) |
| 185 | (depth |
| 186 | :allocation :virtual |
| 187 | :getter "gdk_drawable_get_depth" |
| 188 | :reader drawable-depth |
| 189 | :type int) |
| 190 | (with |
| 191 | :allocation :virtual |
| 192 | :getter drawable-width) |
| 193 | (height |
| 194 | :allocation :virtual |
| 195 | :getter drawable-height))) |
| 196 | |
| 197 | ("GdkWindow" |
| 198 | :slots |
| 199 | ((state |
| 200 | :allocation :virtual |
| 201 | :getter "gdk_window_get_state" |
| 202 | :reader window-state |
| 203 | :type window-state) |
| 204 | (parent |
| 205 | :allocation :virtual |
| 206 | :getter "gdk_window_get_parent" |
| 207 | :reader window-parent |
| 208 | :type window) |
| 209 | (toplevel |
| 210 | :allocation :virtual |
| 211 | :getter "gdk_window_get_toplevel" |
| 212 | :reader window-toplevel |
| 213 | :type window) |
| 214 | (children |
| 215 | :allocation :virtual |
| 216 | :getter "gdk_window_get_children" |
| 217 | :reader window-children |
| 218 | :type (glist window)) |
| 219 | (events |
| 220 | :allocation :virtual |
| 221 | :getter "gdk_window_get_events" |
| 222 | :setter "gdk_window_set_events" |
| 223 | :accessor window-events |
| 224 | :type event-mask) |
| 225 | (group |
| 226 | :allocation :virtual |
| 227 | :getter "gdk_window_get_group" |
| 228 | :setter "gdk_window_set_group" |
| 229 | :unbound nil |
| 230 | :accessor window-group |
| 231 | :type window) |
| 232 | #?(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0") |
| 233 | (type-hint |
| 234 | :allocation :virtual |
| 235 | :getter "gdk_window_get_type_hint" |
| 236 | :setter "gdk_window_set_type_hint" |
| 237 | :accessor window-type-hint |
| 238 | :type window-type-hint) |
| 239 | #?-(pkg-exists-p "gtk+-2.0" :atleast-version "2.10.0") |
| 240 | (type-hint |
| 241 | :allocation :virtual |
| 242 | :getter "gdk_window_get_type_hint" |
| 243 | :accessor window-type-hint |
| 244 | :type window-type-hint) |
| 245 | (decorations |
| 246 | :allocation :virtual |
| 247 | :getter %window-decoration-getter |
| 248 | :setter "gdk_window_set_decoration" |
| 249 | :boundp %window-decoration-boundp |
| 250 | :accessor window-decorations |
| 251 | :type wm-decoration)))) |
| 252 | |
| 253 | |
| 254 | (deftype bitmap () 'pixmap) |
| 255 | |
| 256 | (defclass cursor (boxed) |
| 257 | ((type |
| 258 | :allocation :alien |
| 259 | :reader cursor-type |
| 260 | :type cursor-type) |
| 261 | (ref-count |
| 262 | :allocation :alien |
| 263 | :type unsigned-int) |
| 264 | (display |
| 265 | :allocation :virtual |
| 266 | :getter "gdk_cursor_get_display" |
| 267 | :reader cursor-display |
| 268 | :type display)) |
| 269 | (:metaclass boxed-class) |
| 270 | (:ref %cursor-ref) |
| 271 | (:unref %cursor-unref)) |
| 272 | |
| 273 | |
| 274 | (defclass geometry (struct) |
| 275 | ((min-width |
| 276 | :allocation :alien |
| 277 | :accessor geometry-min-width |
| 278 | :initarg :min-width |
| 279 | :type int) |
| 280 | (min-height |
| 281 | :allocation :alien |
| 282 | :accessor geometry-min-height |
| 283 | :initarg :min-height |
| 284 | :type int) |
| 285 | (max-width |
| 286 | :allocation :alien |
| 287 | :accessor geometry-max-width |
| 288 | :initarg :max-width |
| 289 | :type int) |
| 290 | (max-height |
| 291 | :allocation :alien |
| 292 | :accessor geometry-max-height |
| 293 | :initarg :max-height |
| 294 | :type int) |
| 295 | (base-width |
| 296 | :allocation :alien |
| 297 | :accessor geometry-base-width |
| 298 | :initarg :base-width |
| 299 | :type int) |
| 300 | (base-height |
| 301 | :allocation :alien |
| 302 | :accessor geometry-base-height |
| 303 | :initarg :base-height |
| 304 | :type int) |
| 305 | (width-inc |
| 306 | :allocation :alien |
| 307 | :accessor geometry-width-inc |
| 308 | :initarg :width-inc |
| 309 | :type int) |
| 310 | (height-inc |
| 311 | :allocation :alien |
| 312 | :accessor geometry-height-inc |
| 313 | :initarg :height-inc |
| 314 | :type int) |
| 315 | (min-aspect |
| 316 | :allocation :alien |
| 317 | :accessor geometry-min-aspect |
| 318 | :initarg :min-aspect |
| 319 | :type double-float) |
| 320 | (max-aspect |
| 321 | :allocation :alien |
| 322 | :accessor geometry-max-aspect |
| 323 | :initarg :max-aspect |
| 324 | :type double-float) |
| 325 | (gravity |
| 326 | :allocation :alien |
| 327 | :accessor geometry-gravity |
| 328 | :initarg :gravity |
| 329 | :type gravity)) |
| 330 | (:metaclass struct-class)) |
| 331 | |
| 332 | (deftype native-window () '(unsigned 32)) |