;;;; xosd.scm ; ; Copyright (c) 2000-2011, Felix L. Winkelmann ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following ; conditions are met: ; ; Redistributions of source code must retain the above copyright notice, this list of conditions and the following ; disclaimer. ; Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following ; disclaimer in the documentation and/or other materials provided with the distribution. ; Neither the name of the author nor the names of its contributors may be used to endorse or promote ; products derived from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS ; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR ; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ; POSSIBILITY OF SUCH DAMAGE. ; ; Send bugs, suggestions and ideas to: ; ; felix@call-with-current-continuation.org ; ; Felix L. Winkelmann ; Unter den Gleichen 1 ; 37130 Gleichen ; Germany #> #include <# (module xosd (xosd:create xosd:destroy xosd:is-onscreen? xosd:wait-until-no-display xosd:hide xosd:show xosd:set-pos xosd:set-vertical-offset xosd:set-horizontal-offset xosd:set-align xosd:set-shadow-offset xosd:set-outline-offset xosd:set-timeout xosd:set-font xosd:scroll xosd:set-colour xosd:set-outline-colour xosd:set-shadow-colour xosd:get-colour xosd:get-number-lines xosd:set-bar-length xosd:display) (import scheme chicken (except foreign foreign-declare) easyffi) (use data-structures) (define-record xosd ptr) (define (sym->align s) (case s [(left) xosd:left] [(right) xosd:right] [(center) xosd:center] [else (error "invalid alignment" s)] ) ) (define (sym->pos s) (case s [(top) xosd:top] [(middle) xosd:middle] [(bottom) xosd:bottom] [else (error "invalid alignment" s)] ) ) #>? ___declare(default_renaming, "") ___declare(substitute, "^xosd-;xosd:") ___declare(opaque, "xosdptr;(c-pointer \"xosd\")") ___declare(type, "xalign;int;sym->align") ___declare(type, "xpos;int;sym->pos") ___declare(rename, "xosd_is_onscreen;xosd:is-onscreen?") const int XOSD_top, XOSD_bottom, XOSD_middle; const int XOSD_left, XOSD_center, XOSD_right; xosdptr xosd_create(int number_lines); int xosd_destroy (xosdptr osd); int xosd_is_onscreen(xosdptr osd); int xosd_wait_until_no_display(xosdptr osd); int xosd_hide (xosdptr osd); int xosd_show (xosdptr osd); int xosd_set_pos (xosdptr osd, xpos pos); int xosd_set_vertical_offset (xosdptr osd, int offset); int xosd_set_horizontal_offset (xosdptr osd, int offset); int xosd_set_align (xosdptr osd, xalign align); int xosd_set_shadow_offset (xosdptr osd, int shadow_offset); int xosd_set_outline_offset (xosdptr osd, int shadow_offset); int xosd_set_timeout (xosdptr osd, int timeout); int xosd_set_font (xosdptr osd, char* font); int xosd_set_colour (xosdptr osd, char* colour); int xosd_set_outline_colour (xosdptr osd, char* colour); int xosd_set_shadow_colour (xosdptr osd, char* colour); void xosd_get_colour (xosdptr osd, ___out int* red, ___out int* green, ___out int* blue); int xosd_scroll (xosdptr osd, int lines); int xosd_get_number_lines ( xosdptr osd); int xosd_set_bar_length(xosdptr, int); <# #>! static int xosd_display_string (xosdptr osd, int line, char *str) { return xosd_display(osd, line, XOSD_string, str); } static int xosd_display_slider (xosdptr osd, int line, int n) { return xosd_display(osd, line, XOSD_slider, n); } static int xosd_display_percentage (xosdptr osd, int line, int n) { return xosd_display(osd, line, XOSD_percentage, n); } <# (define (xosd:display osd ln m #!optional x) (case m [(slider) (xosd:display-slider osd ln (or x 0))] [(percentage) (xosd:display-percentage osd ln (or x 0))] [(string) (xosd:display-string osd ln (or x ""))] [else (if (integer? m) (xosd:display-percentage osd ln m) (xosd:display-string osd ln (->string m)) ) ] ) ) )