#!/opt/openisis/tcl/tkbuild/wish # # openisis - an open implementation of the ISIS database # Version 0.8.x (microversion see file Version) # Copyright (C) 2003 by Erik Grziwotz, erik@openisis.org # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # This software is dedicated to the memory of Eckart Dietrich. # # This software is inspired by (but contains no code of) the iAPI # Copyright (C) 2000 by Robert Janusz, rj@jezuici.krakow.pl. # See iAPI.txt for what it contains. # # $Id: lp,v 1.6 2003/02/17 11:27:23 kripke Exp $ # # lowerpoint :) # # usage: lp [db [encoding [ptSz]]] # default encoding is cp850 ("DOS Latin1"), you may want iso8859-1 or utf8 # default font point size is 240, try 180 # # consult documentation of your window manager # on how to tell it to put no frames on this window # openIsisInit set dbname [expr {$argc ? [lindex $argv 0] : {db/cds/cds}}] set enc [expr {1 < $argc ? [lindex $argv 1] : {cp850}}] set pt [expr {2 < $argc ? [lindex $argv 2] : {240}}] set db [openIsisOpen $dbname] set max [$db maxrowid] set cur 0 # puts "$db $dbname $max" # configure look set sw [winfo screenwidth .] set sh [winfo screenheight .] set tw [expr $sw - 400] set lh [expr $pt / 6] ;# line height set fn "-*-new century schoolbook-medium-r-*-*-*-$pt-75-75-*-*-iso10646-1" set dot img/isi.gif set logo img/logo.gif set cursor {@img/isi.cursor black} proc show n { global db cur max lh tw fn enc switch -- $n \ + { if {$max == $cur} return; incr cur } - { if {1 == $cur} return; incr cur -1 } default { if {$cur == $n} return; set cur $n } .c delete t set y 100 set rec [$db read $cur] if {"utf-8" != $enc} {set rec [encoding convertfrom $enc $rec]} set f [lindex $rec 0] regexp {([^\t]*)(\t(.*))?} [lindex $f 1] - text - next set it [.c create text 150 $y \ -anchor nw -font $fn -width $tw -tags t -text $text] if {"" != $next} { set ny [expr [lindex [.c bbox $it] 3] + $lh/4] set it [.c create text 210 $ny \ -anchor nw -font $fn -width $tw -tags t -fill darkgreen -text $next] } set ny [lindex [.c bbox t] 3] .c lower [.c create rectangle 120 [expr $y-2] [expr 150+$tw] $ny \ -tags t -outline lightgrey -fill lightgrey] set y [expr $ny + 2*$lh] foreach f [lrange $rec 1 end] { regexp {([^\t]*)(\t(.*))?} [lindex $f 1] - text - next if [string match *.gif $text] { regexp {(.*/)?(.*)} $text - - text if ![catch {image create photo $text -file img/$text}] { set it [.c create image 150 $y -anchor nw -tags t -image $text] set y [expr [lindex [.c bbox $it] 3] + $lh] continue } } .c create image 120 $y -anchor nw -tags t -image dot set it [.c create text 150 $y \ -anchor nw -font $fn -width $tw -tags t -text $text] if {"" != $next} { set y [expr [lindex [.c bbox $it] 3] + $lh/4] set it [.c create text 210 $y \ -anchor nw -font $fn -width $tw -tags t -fill darkgreen -text $next] } set y [expr [lindex [.c bbox $it] 3] + $lh] } .c itemconfigure counter -text "http://openisis.org/ $cur / $max" };# show proc print {} { # A4dj 595 842 24 50 571 818 # interior on Deskjet landscape is 768*547 # to keep 4x3 ratio use 728x546 .c postscript -rotate 1 -pagewidth 728 -file /tmp/lp.ps };# print proc printall {} { global cur max set f [open /tmp/lp.ps w] set o $cur for {set i 1} {$i <= $max} {incr i} { show $i .c postscript -rotate 1 -pagewidth 728 -channel $f } close $f show $o };# printall # create widgets canvas .c -width $sw -height $sh -bg white catch {.c configure -cursor $cursor} bind .c exit bind .c q exit bind .c - {show -} bind .c b {show -} bind .c p print bind .c P printall bind .c {show -} bind .c {show -} bind .c {show 1} bind .c "show $max" bind .c {show +} bind .c {show +} if [catch {image create photo logo -file $logo} err] { puts stderr "error loading logo '$logo':\n\t$err" } else { .c create image [expr $sw - 150] 150 -tags logo -image logo } if [catch {image create photo dot -file $dot} err] { # builtin image create bitmap dot -data { #define isi_width 16 #define isi_height 16 #define isi_x_hot 1 #define isi_y_hot 5 static unsigned char isi_bits[] = { 0x00, 0x00, 0x00, 0x18, 0x80, 0x25, 0xc0, 0x27, 0xe0, 0x47, 0xfe, 0x27, 0xe4, 0x27, 0xc4, 0x23, 0x08, 0x10, 0x10, 0x08, 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x07, 0x00, 0x00}; } } .c create text [expr $sw - 100] [expr $sh - 50] -tags counter -text 0 show 1 pack .c -expand 1 -fill both focus .c wm geometry . ${sw}x${sh}+0+0 # if [wm frame .] ... # puts stderr "for real fullscreen experience tell your wm to not decorate me"