1 |
dpavlin |
604 |
#!/usr/bin/wish |
2 |
|
|
# |
3 |
|
|
#/* |
4 |
|
|
# The Malete project - the Z39.2/Z39.50 database framework of OpenIsis. |
5 |
|
|
# Version 0.9.x (patchlevel see file Version) |
6 |
|
|
# Copyright (C) 2001-2004 by Erik Grziwotz, erik@openisis.org |
7 |
|
|
# |
8 |
|
|
# This library is free software; you can redistribute it and/or |
9 |
|
|
# modify it under the terms of the GNU Lesser General Public |
10 |
|
|
# License as published by the Free Software Foundation; either |
11 |
|
|
# version 2.1 of the License, or (at your option) any later version. |
12 |
|
|
# |
13 |
|
|
# This library is distributed in the hope that it will be useful, |
14 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 |
|
|
# See the GNU Lesser General Public License for more details. |
17 |
|
|
# |
18 |
|
|
# You should have received a copy of the GNU Lesser General Public |
19 |
|
|
# License along with this library; if not, write to the Free Software |
20 |
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
|
|
# |
22 |
|
|
# see README for more information |
23 |
|
|
#EOH */ |
24 |
|
|
# |
25 |
|
|
# $Id: lp,v 1.2 2004/11/04 13:23:03 kripke Exp $ |
26 |
|
|
# |
27 |
|
|
# lowerpoint :) |
28 |
|
|
# |
29 |
|
|
# usage: lp [file [encoding [ptSz]]] |
30 |
|
|
# default encoding is cp850 ("DOS Latin1"), you may want iso8859-1 or utf8 |
31 |
|
|
# default font point size is 240, try 180 |
32 |
|
|
# |
33 |
|
|
# consult documentation of your window manager |
34 |
|
|
# on how to tell it to put no frames on this window |
35 |
|
|
# |
36 |
|
|
|
37 |
|
|
set filename [expr {$argc ? [lindex $argv 0] : {doc/OverView.txt}}] |
38 |
|
|
set enc [expr {1 < $argc ? [lindex $argv 1] : {iso8859-1}}] |
39 |
|
|
set pt [expr {2 < $argc ? [lindex $argv 2] : {240}}] |
40 |
|
|
set cur 0 |
41 |
|
|
# puts "$db $filename $max" |
42 |
|
|
|
43 |
|
|
# configure look |
44 |
|
|
set sw [winfo screenwidth .] |
45 |
|
|
set sh [winfo screenheight .] |
46 |
|
|
set tw [expr $sw - 400] |
47 |
|
|
set lh [expr $pt / 6] ;# line height |
48 |
|
|
set fn "-*-new century schoolbook-medium-r-*-*-*-$pt-75-75-*-*-iso10646-1" |
49 |
|
|
set dot img/isi.gif |
50 |
|
|
set logo img/logo.gif |
51 |
|
|
set cursor {@img/isi.cursor black} |
52 |
|
|
|
53 |
|
|
# read text |
54 |
|
|
proc load {} { |
55 |
|
|
global items title body page filename cur enc |
56 |
|
|
catch {unset items title body} |
57 |
|
|
set fid [open $filename] |
58 |
|
|
fconfigure $fid -encoding $enc |
59 |
|
|
|
60 |
|
|
set title([set page 0]) "" |
61 |
|
|
set items(-1) 0 ;# page i has items items(i-1)+1 .. items(i) |
62 |
|
|
set items(0) [set item 1] |
63 |
|
|
|
64 |
|
|
while {0 <= [gets $fid line]} { |
65 |
|
|
if {[string eq "" $line]} continue |
66 |
|
|
set ind [string index $line 0] |
67 |
|
|
if {[string eq * $ind]} { |
68 |
|
|
incr page |
69 |
|
|
set title($page) [string ran $line 2 end] |
70 |
|
|
set items($page) [incr item] |
71 |
|
|
set body($item) "" |
72 |
|
|
continue |
73 |
|
|
} |
74 |
|
|
if {[string eq - $ind]} { |
75 |
|
|
set items($page) [incr item] |
76 |
|
|
set body($item) [string ran $line 2 end] |
77 |
|
|
continue |
78 |
|
|
} |
79 |
|
|
append body($item) " " [string trim $line] |
80 |
|
|
} |
81 |
|
|
close $fid |
82 |
|
|
puts "$page pages" |
83 |
|
|
show $cur |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
proc show n { |
87 |
|
|
global items title body cur page lh tw fn enc |
88 |
|
|
switch -- $n \ |
89 |
|
|
+ { if {$page == $cur} return; incr cur |
90 |
|
|
} - { if {!$cur} return; incr cur -1 |
91 |
|
|
} end { set cur $page |
92 |
|
|
} default { set cur $n |
93 |
|
|
} |
94 |
|
|
.c delete t |
95 |
|
|
set y 100 |
96 |
|
|
if {[string comp "" $title($cur)]} { |
97 |
|
|
set it [.c create text 150 $y \ |
98 |
|
|
-anchor nw -font $fn -width $tw -tags t -text $title($cur)] |
99 |
|
|
# bg box |
100 |
|
|
set ny [lindex [.c bbox t] 3] |
101 |
|
|
.c lower [.c create rectangle 120 [expr $y-2] [expr 150+$tw] $ny \ |
102 |
|
|
-tags t -outline lightgrey -fill lightgrey] |
103 |
|
|
set y [expr $ny + 2*$lh] |
104 |
|
|
} |
105 |
|
|
set i $items([expr {$cur-1}]) |
106 |
|
|
set max $items($cur) |
107 |
|
|
set dot 0 |
108 |
|
|
puts "page $cur items $i..$max" |
109 |
|
|
while {$max >= [incr i]} { |
110 |
|
|
# if {0 && [string match *.gif $text]} { |
111 |
|
|
# regexp {(.*/)?(.*)} $text - - text |
112 |
|
|
# if ![catch {image create photo $text -file img/$text}] { |
113 |
|
|
# set it [.c create image 150 $y -anchor nw -tags t -image $text] |
114 |
|
|
# set y [expr [lindex [.c bbox $it] 3] + $lh] |
115 |
|
|
# continue |
116 |
|
|
# } |
117 |
|
|
# } |
118 |
|
|
if {$dot} {.c create image 120 $y -anchor nw -tags t -image dot} |
119 |
|
|
set dot 1 |
120 |
|
|
set it [.c create text 150 $y \ |
121 |
|
|
-anchor nw -font $fn -width $tw -tags t -text $body($i)] |
122 |
|
|
# if {"" != $next} { |
123 |
|
|
# set y [expr [lindex [.c bbox $it] 3] + $lh/4] |
124 |
|
|
# set it [.c create text 210 $y \ |
125 |
|
|
# -anchor nw -font $fn -width $tw -tags t -fill darkgreen -text $next] |
126 |
|
|
# } |
127 |
|
|
set y [expr [lindex [.c bbox $it] 3] + $lh] |
128 |
|
|
} |
129 |
|
|
.c itemconfigure counter -text "http://openisis.org/ $cur / $page" |
130 |
|
|
};# show |
131 |
|
|
|
132 |
|
|
|
133 |
|
|
proc print {} { |
134 |
|
|
# A4dj 595 842 24 50 571 818 |
135 |
|
|
# interior on Deskjet landscape is 768*547 |
136 |
|
|
# to keep 4x3 ratio use 728x546 |
137 |
|
|
.c postscript -rotate 1 -pagewidth 728 -file /tmp/lp.ps |
138 |
|
|
};# print |
139 |
|
|
|
140 |
|
|
proc printall {} { |
141 |
|
|
global cur max |
142 |
|
|
set f [open /tmp/lp.ps w] |
143 |
|
|
set o $cur |
144 |
|
|
for {set i 1} {$i <= $max} {incr i} { |
145 |
|
|
show $i |
146 |
|
|
.c postscript -rotate 1 -pagewidth 728 -channel $f |
147 |
|
|
} |
148 |
|
|
close $f |
149 |
|
|
show $o |
150 |
|
|
};# printall |
151 |
|
|
|
152 |
|
|
|
153 |
|
|
# create widgets |
154 |
|
|
|
155 |
|
|
canvas .c -width $sw -height $sh -bg white |
156 |
|
|
catch {.c configure -cursor $cursor} |
157 |
|
|
bind .c <Escape> exit |
158 |
|
|
bind .c q exit |
159 |
|
|
bind .c - {show -} |
160 |
|
|
bind .c b {show -} |
161 |
|
|
bind .c p print |
162 |
|
|
bind .c P printall |
163 |
|
|
bind .c r load |
164 |
|
|
bind .c <Up> {show -} |
165 |
|
|
bind .c <Button-3> {show -} |
166 |
|
|
bind .c <Home> {show 0} |
167 |
|
|
bind .c <End> "show end" |
168 |
|
|
bind .c <KeyPress> {show +} |
169 |
|
|
bind .c <Button-1> {show +} |
170 |
|
|
|
171 |
|
|
if [catch {image create photo logo -file $logo} err] { |
172 |
|
|
puts stderr "error loading logo '$logo':\n\t$err" |
173 |
|
|
} else { |
174 |
|
|
.c create image [expr $sw - 150] 150 -tags logo -image logo |
175 |
|
|
} |
176 |
|
|
if [catch {image create photo dot -file $dot} err] { |
177 |
|
|
# builtin |
178 |
|
|
image create bitmap dot -data { |
179 |
|
|
#define isi_width 16 |
180 |
|
|
#define isi_height 16 |
181 |
|
|
#define isi_x_hot 1 |
182 |
|
|
#define isi_y_hot 5 |
183 |
|
|
static unsigned char isi_bits[] = { |
184 |
|
|
0x00, 0x00, 0x00, 0x18, 0x80, 0x25, 0xc0, 0x27, 0xe0, 0x47, 0xfe, 0x27, |
185 |
|
|
0xe4, 0x27, 0xc4, 0x23, 0x08, 0x10, 0x10, 0x08, 0xe0, 0x07, 0xc0, 0x03, |
186 |
|
|
0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x07, 0x00, 0x00}; |
187 |
|
|
} |
188 |
|
|
} |
189 |
|
|
.c create text [expr $sw - 100] [expr $sh - 50] -tags counter -text 0 |
190 |
|
|
|
191 |
|
|
load |
192 |
|
|
|
193 |
|
|
pack .c -expand 1 -fill both |
194 |
|
|
focus .c |
195 |
|
|
wm geometry . ${sw}x${sh}+0+0 |
196 |
|
|
# if [wm frame .] ... |
197 |
|
|
# puts stderr "for real fullscreen experience tell your wm to not decorate me" |