| 1 | ;; Common Lisp bindings for librsvg |
| 2 | ;; Copyright 2005 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: rsvg.lisp,v 1.5 2006-08-30 11:08:13 espen Exp $ |
| 24 | |
| 25 | (in-package "RSVG") |
| 26 | |
| 27 | |
| 28 | (eval-when (:compile-toplevel :load-toplevel :execute) |
| 29 | (init-types-in-library |
| 30 | #.(concatenate 'string (pkg-config:pkg-variable "librsvg-2.0" "libdir") |
| 31 | "/librsvg-2." asdf:*dso-extension*) :prefix "rsvg_") |
| 32 | |
| 33 | (define-types-by-introspection "Rsvg" |
| 34 | ("RsvgError" :ignore t))) |
| 35 | |
| 36 | |
| 37 | (defbinding init () nil) |
| 38 | (defbinding term () nil) |
| 39 | |
| 40 | (defbinding (set-default-dpi "rsvg_set_default_dpi_x_y") (dpi-x &optional (dpi-y dpi-x)) nil |
| 41 | (dpi-x double-float) |
| 42 | (dpi-y double-float)) |
| 43 | |
| 44 | |
| 45 | (defbinding handle-write () boolean |
| 46 | (handle handle) |
| 47 | (data string) |
| 48 | ((length data) int) ; TODO: compute propper length of utf8 string |
| 49 | (nil gerror-signal :out)) |
| 50 | |
| 51 | (defbinding handle-close () boolean |
| 52 | (handle handle) |
| 53 | (nil gerror-signal :out)) |
| 54 | |
| 55 | (defbinding (handle-get-pixbuf "rsvg_handle_get_pixbuf_sub") (handle &optional id) boolean |
| 56 | (handle handle) |
| 57 | (id (or null string))) |
| 58 | |
| 59 | |
| 60 | (defbinding %handle-new-from-data () pointer |
| 61 | (data string) |
| 62 | ((length data) int) ; TODO: compute propper length of utf8 string |
| 63 | (nil gerror-signal :out)) |
| 64 | |
| 65 | (defbinding %handle-new-from-file () pointer |
| 66 | (filename pathname) |
| 67 | (nil gerror-signal :out)) |
| 68 | |
| 69 | (defmethod allocate-foreign ((handle handle) &key data filename) |
| 70 | (cond |
| 71 | (filename (%handle-new-from-file filename)) |
| 72 | (data (%handle-new-from-data data)) |
| 73 | (t (call-next-method)))) |
| 74 | |
| 75 | |
| 76 | ;;; Cairo interface |
| 77 | |
| 78 | (defbinding (render-cairo "rsvg_handle_render_cairo_sub") (handle cr &optional id) nil |
| 79 | (handle handle) |
| 80 | (cr cairo:context) |
| 81 | (id (or null string))) |