| 1 | ;; Common Lisp bindings for GTK+ v2.0 |
| 2 | ;; Copyright (C) 1999-2001 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: gtktree.lisp,v 1.1 2004-11-07 17:22:06 espen Exp $ |
| 19 | |
| 20 | |
| 21 | (in-package "GTK") |
| 22 | |
| 23 | |
| 24 | ;;;; Cell Layout |
| 25 | |
| 26 | (defbinding cell-layout-pack-start () nil |
| 27 | (cell-layout cell-layout) |
| 28 | (cell cell-renderer) |
| 29 | (expand boolean)) |
| 30 | |
| 31 | (defbinding cell-layout-pack-end () nil |
| 32 | (cell-layout cell-layout) |
| 33 | (cell cell-renderer) |
| 34 | (expand boolean)) |
| 35 | |
| 36 | (defun cell-layout-pack (layout cell &key end expand) |
| 37 | (if end |
| 38 | (cell-layout-pack-end layout cell expand) |
| 39 | (cell-layout-pack-start layout cell expand))) |
| 40 | |
| 41 | (defbinding cell-layout-reorder () nil |
| 42 | (cell-layout cell-layout) |
| 43 | (cell cell-renderer) |
| 44 | (position int)) |
| 45 | |
| 46 | (defbinding cell-layout-clear () nil |
| 47 | (cell-layout cell-layout)) |
| 48 | |
| 49 | (defbinding cell-layout-add-attribute (cell-layout cell attribute column) nil |
| 50 | (cell-layout cell-layout) |
| 51 | (cell cell-renderer) |
| 52 | ((string-downcase attribute) string) |
| 53 | (column int)) |
| 54 | |
| 55 | (def-callback-marshal %cell-layout-data-func |
| 56 | (nil cell-layout cell-renderer tree-model tree-iter)) |
| 57 | |
| 58 | (defbinding cell-layout-set-cell-data-func (cell-layout cell function) nil |
| 59 | (cell-layout cell-layout) |
| 60 | (cell cell-renderer) |
| 61 | ((callback %cell-layout-data-func) pointer) |
| 62 | ((register-callback-function function) unsigned-int) |
| 63 | ((callback %destroy-user-data) pointer)) |
| 64 | |
| 65 | (defbinding cell-layout-clear-attributes () nil |
| 66 | (cell-layout cell-layout) |
| 67 | (cell cell-renderer)) |
| 68 | |
| 69 | |
| 70 | |
| 71 | ;;;; List Store |
| 72 | |
| 73 | (defmethod initialize-instance ((list-store list-store) &key columns) |
| 74 | (call-next-method) |
| 75 | (%list-store-set-column-types list-store (length columns) |
| 76 | (map 'vector #'find-type-number columns))) |
| 77 | |
| 78 | |
| 79 | (defbinding %list-store-set-column-types () nil |
| 80 | (list-store list-store) |
| 81 | (n-columns unsigned-int) |
| 82 | (columns (vector type-number))) |
| 83 | |
| 84 | (defbinding %list-store-set-value () nil |
| 85 | (list-store list-store) |
| 86 | (tree-iter tree-iter) |
| 87 | (column int) |
| 88 | (value gvalue)) |
| 89 | |
| 90 | (defun list-store-set-value (list-store tree-iter column type value) |
| 91 | (let ((gvalue (gvalue-new type value))) |
| 92 | (unwind-protect |
| 93 | (%list-store-set-value list-store tree-iter column gvalue) |
| 94 | (gvalue-free gvalue)))) |
| 95 | |
| 96 | (defbinding list-store-remove () boolean |
| 97 | (list-store list-store) |
| 98 | (tree-iter tree-iter)) |
| 99 | |
| 100 | (defbinding list-store-insert () nil |
| 101 | (list-store list-store) |
| 102 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 103 | (position int)) |
| 104 | |
| 105 | (defbinding list-store-insert-before (list-store &optional sibling) nil |
| 106 | (list-store list-store) |
| 107 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 108 | (sibling (or null tree-iter))) |
| 109 | |
| 110 | (defbinding list-store-insert-after (list-store &optional sibling) nil |
| 111 | (list-store list-store) |
| 112 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 113 | (sibling (or null tree-iter))) |
| 114 | |
| 115 | (defbinding list-store-prepend () nil |
| 116 | (list-store list-store) |
| 117 | ((make-instance 'tree-iter) tree-iter :in-out)) |
| 118 | |
| 119 | (defbinding list-store-append () nil |
| 120 | (list-store list-store) |
| 121 | ((make-instance 'tree-iter) tree-iter :in-out)) |
| 122 | |
| 123 | (defbinding list-store-clear () nil |
| 124 | (list-store list-store)) |
| 125 | |
| 126 | (defbinding list-store-reorder () nil |
| 127 | (list-store list-store) |
| 128 | (new-order (vector int))) |
| 129 | |
| 130 | (defbinding list-store-swap () nil |
| 131 | (list-store list-store) |
| 132 | (a tree-iter) |
| 133 | (b tree-iter)) |
| 134 | |
| 135 | (defbinding list-store-move-before () nil |
| 136 | (list-store list-store) |
| 137 | (iter tree-iter) |
| 138 | (psoition (or null tree-iter))) |
| 139 | |
| 140 | |
| 141 | (defbinding list-store-move-after () nil |
| 142 | (list-store list-store) |
| 143 | (iter tree-iter) |
| 144 | (psoition tree-iter)) |
| 145 | |
| 146 | |
| 147 | ;;; Tree Model |
| 148 | |
| 149 | |
| 150 | |
| 151 | ;;; Tree Store |
| 152 | |
| 153 | (defbinding %tree-store-set-column-types () nil |
| 154 | (tree-store tree-store) |
| 155 | (n-columns unsigned-int) |
| 156 | (columns (vector type-number))) |
| 157 | |
| 158 | (defmethod initialize-instance ((tree-store tree-store) &key columns) |
| 159 | (call-next-method) |
| 160 | (%tree-store-set-column-types tree-store (length columns) |
| 161 | (map 'vector #'find-type-number columns))) |
| 162 | |
| 163 | |
| 164 | (defbinding %tree-store-set-value () nil |
| 165 | (tree-store tree-store) |
| 166 | (tree-iter tree-iter) |
| 167 | (column int) |
| 168 | (value gvalue)) |
| 169 | |
| 170 | (defbinding tree-store-remove () boolean |
| 171 | (tree-store tree-store) |
| 172 | (tree-iter tree-iter)) |
| 173 | |
| 174 | (defbinding tree-store-insert (tree-store position &optional parent) nil |
| 175 | (tree-store tree-store) |
| 176 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 177 | (parent (or null tree-iter)) |
| 178 | (position int)) |
| 179 | |
| 180 | (defbinding tree-store-insert-before (tree-store &optional parent sibling) nil |
| 181 | (tree-store tree-store) |
| 182 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 183 | (parent (or null tree-iter)) |
| 184 | (sibling (or null tree-iter))) |
| 185 | |
| 186 | (defbinding tree-store-insert-after (tree-store &optional parent sibling) nil |
| 187 | (tree-store tree-store) |
| 188 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 189 | (parent (or null tree-iter)) |
| 190 | (sibling (or null tree-iter))) |
| 191 | |
| 192 | (defbinding tree-store-prepend (tree-store &optional parent) nil |
| 193 | (tree-store tree-store) |
| 194 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 195 | (parent (or null tree-iter))) |
| 196 | |
| 197 | (defbinding tree-store-append (tree-store &optional parent) nil |
| 198 | (tree-store tree-store) |
| 199 | ((make-instance 'tree-iter) tree-iter :in-out) |
| 200 | (parent (or null tree-iter))) |
| 201 | |
| 202 | (defbinding (tree-store-is-ancestor-p "gtk_tree_store_is_ancestor") () boolean |
| 203 | (tree-store tree-store) |
| 204 | (tree-iter tree-iter) |
| 205 | (descendant tree-iter)) |
| 206 | |
| 207 | (defbinding tree-store-iter-depth () int |
| 208 | (tree-store tree-store) |
| 209 | (tree-iter tree-iter)) |
| 210 | |
| 211 | (defbinding tree-store-clear () nil |
| 212 | (tree-store tree-store)) |
| 213 | |
| 214 | (defbinding tree-store-reorder () nil |
| 215 | (tree-store tree-store) |
| 216 | (parent tree-iter) |
| 217 | (new-order (vector int))) |
| 218 | |
| 219 | (defbinding tree-store-swap () nil |
| 220 | (tree-store tree-store) |
| 221 | (a tree-iter) |
| 222 | (b tree-iter)) |
| 223 | |
| 224 | (defbinding tree-store-move-before () nil |
| 225 | (tree-store tree-store) |
| 226 | (iter tree-iter) |
| 227 | (psoition (or null tree-iter))) |
| 228 | |
| 229 | |
| 230 | (defbinding tree-store-move-after () nil |
| 231 | (tree-store tree-store) |
| 232 | (iter tree-iter) |
| 233 | (psoition tree-iter)) |
| 234 | |
| 235 | |
| 236 | |
| 237 | ;;; Tree View |
| 238 | |
| 239 | (defbinding tree-view-get-selection () tree-selection |
| 240 | (tree-view tree-view)) |
| 241 | |
| 242 | (defbinding tree-view-columns-autosize () nil |
| 243 | (tree-view tree-view)) |
| 244 | |
| 245 | (defbinding tree-view-append-column () int |
| 246 | (tree-view tree-view) |
| 247 | (tree-view-column tree-view-column)) |
| 248 | |
| 249 | (defbinding tree-view-remove-column () int |
| 250 | (tree-view tree-view) |
| 251 | (tree-view-column tree-view-column)) |
| 252 | |
| 253 | (defbinding tree-view-insert-column (view columnd position) int |
| 254 | (view tree-view) |
| 255 | (column tree-view-column) |
| 256 | ((if (eq position :end) -1 position) int)) |
| 257 | |
| 258 | (defbinding tree-view-get-column () tree-view-column |
| 259 | (tree-view tree-view) |
| 260 | (position int)) |
| 261 | |
| 262 | (defbinding tree-view-move-column-after () nil |
| 263 | (tree-view tree-view) |
| 264 | (column tree-view-column) |
| 265 | (base-column (or null tree-view-column))) |
| 266 | |
| 267 | ;;(defbinding tree-view-set-column drag-function ...) |
| 268 | |
| 269 | (defbinding tree-view-scroll-to-point () nil |
| 270 | (tree-view tree-view) |
| 271 | (tree-x int) |
| 272 | (tree-y int)) |
| 273 | |
| 274 | (defbinding tree-view-scroll-to-cell () nil |
| 275 | (tree-view tree-view) |
| 276 | (path (or null tree-path)) |
| 277 | (column (or null tree-view-column)) |
| 278 | (use-align boolean) |
| 279 | (row-align single-float) |
| 280 | (col-align single-float)) |
| 281 | |
| 282 | (defbinding tree-view-set-cursor () nil |
| 283 | (tree-view tree-view) |
| 284 | (path tree-path) |
| 285 | (focus-column tree-view-column) |
| 286 | (start-editing boolean)) |
| 287 | |
| 288 | (defbinding tree-view-set-cursor-on-cell () nil |
| 289 | (tree-view tree-view) |
| 290 | (path tree-path) |
| 291 | (focus-column (or null tree-view-column)) |
| 292 | (focus-cell (or null cell-renderer)) |
| 293 | (start-editing boolean)) |
| 294 | |
| 295 | (defbinding tree-view-get-cursor () nil |
| 296 | (tree-view tree-view) |
| 297 | (path tree-path :out ) |
| 298 | (focus-column tree-view-column :out)) |
| 299 | |
| 300 | (defbinding tree-view-row-activated () nil |
| 301 | (tree-view tree-view) |
| 302 | (path tree-path ) |
| 303 | (column tree-view-column)) |
| 304 | |
| 305 | (defbinding tree-view-expand-all () nil |
| 306 | (tree-view tree-view)) |
| 307 | |
| 308 | (defbinding tree-view-collapse-all () nil |
| 309 | (tree-view tree-view)) |
| 310 | |
| 311 | (defbinding tree-view-expand-to-path () nil |
| 312 | (tree-view tree-view) |
| 313 | (path tree-path)) |
| 314 | |
| 315 | (defbinding tree-view-expand-row () nil |
| 316 | (tree-view tree-view) |
| 317 | (path tree-path) |
| 318 | (open-all boolean)) |
| 319 | |
| 320 | (defbinding tree-view-collapse-row () nil |
| 321 | (tree-view tree-view) |
| 322 | (path tree-path)) |
| 323 | |
| 324 | (def-callback-marshal %tree-view-mapping-func (nil tree-view tree-path)) |
| 325 | |
| 326 | (defbinding %tree-view-map-expanded-rows () nil |
| 327 | (tree-view tree-view) |
| 328 | ((callback %tree-view-mapping-func) pointer) |
| 329 | (callback-id unsigned-int)) |
| 330 | |
| 331 | (defun map-expanded-rows (function tree-view) |
| 332 | (with-callback-function (id function) |
| 333 | (%tree-view-map-expanded-rows tree-view id))) |
| 334 | |
| 335 | (defbinding (tree-view-row-expanded-p "gtk_tree_view_row_expanded") () boolean |
| 336 | (tree-view tree-view) |
| 337 | (path tree-path)) |
| 338 | |
| 339 | (defbinding tree-view-get-path-at-pos |
| 340 | (tree-view x y &optional (cell-x 0) (cell-y 0)) boolean |
| 341 | (tree-view tree-view) |
| 342 | (x int) |
| 343 | (y int) |
| 344 | (path tree-path :out) |
| 345 | (column tree-view-column :out) |
| 346 | (cell-x int) |
| 347 | (cell-y int)) |
| 348 | |
| 349 | (defbinding tree-view-get-cell-area () nil |
| 350 | (tree-view tree-view) |
| 351 | (path (or null tree-path)) |
| 352 | (column (or null tree-view-column)) |
| 353 | ((make-instance 'gdk:rectangle) gdk:rectangle :in-out)) |
| 354 | |
| 355 | (defbinding tree-view-get-background-area () nil |
| 356 | (tree-view tree-view) |
| 357 | (path (or null tree-path)) |
| 358 | (column (or null tree-view-column)) |
| 359 | ((make-instance 'gdk:rectangle) gdk:rectangle :in-out)) |
| 360 | |
| 361 | (defbinding tree-view-get-visible-rect () nil |
| 362 | (tree-view tree-view) |
| 363 | ((make-instance 'gdk:rectangle) gdk:rectangle :in-out)) |
| 364 | |
| 365 | ;; and many more functions which we'll add later |
| 366 | |