version 1.1.1.2, 2000/01/22 14:16:30 |
version 1.1.1.3, 2003/09/15 07:09:39 |
|
|
*/ |
*/ |
if (tk_perl) { |
if (tk_perl) { |
fputs("\ |
fputs("\ |
sub gnuplot {\n\ |
sub {\n\ |
my($can) = @_;\n\ |
my($can) = @_;\n\ |
$can->delete('all');\n\ |
$can->delete('all');\n\ |
my $cmx = ($can->configure(-width))[4];\n\ |
my $cmx = $can->width - 2 * $can->cget(-border) - 2 * $can->cget(-highlightthickness);\n\ |
my $cmy = ($can->configure(-height))[4];\n\ |
|
my $cmx = $can->width - 2 * $can->cget(-border);\n\ |
|
if ($cmx <= 1) {\n$cmx = ($can->cget(-width));\n}\n\ |
if ($cmx <= 1) {\n$cmx = ($can->cget(-width));\n}\n\ |
my $cmy = $can->height - 2 * $can->cget(-border);\n\ |
my $cmy = $can->height - 2 * $can->cget(-border) - 2 * $can->cget(-highlightthickness);\n\ |
if ($cmy <= 1) {\n$cmy = ($can->cget(-height));\n}\n", |
if ($cmy <= 1) {\n$cmy = ($can->cget(-height));\n}\n", |
gpoutfile); |
gpoutfile); |
} else { |
} else { |
fputs("\ |
fputs("\ |
proc gnuplot can {\n\ |
proc gnuplot can {\n\ |
$can delete all\n\ |
$can delete all\n\ |
set cmx [expr [winfo width $can]-2*[$can cget -border]]\n\ |
set cmx [expr [winfo width $can]-2*[$can cget -border]-2*[$can cget -highlightthickness]]\n\ |
if {$cmx <= 1} {set cmx [$can cget -width]}\n\ |
if {$cmx <= 1} {set cmx [$can cget -width]}\n\ |
set cmy [expr [winfo height $can]-2*[$can cget -border]]\n\ |
set cmy [expr [winfo height $can]-2*[$can cget -border]-2*[$can cget -highlightthickness]]\n\ |
if {$cmy <= 1} {set cmy [$can cget -height]}\n", |
if {$cmy <= 1} {set cmy [$can cget -height]}\n", |
gpoutfile); |
gpoutfile); |
} |
} |
Line 370 $can create line \ |
|
Line 368 $can create line \ |
|
|
|
TERM_PUBLIC void |
TERM_PUBLIC void |
TK_put_text(x, y, str) |
TK_put_text(x, y, str) |
unsigned int x, y; |
unsigned int x, y; |
char *str; |
char *str; |
{ |
{ |
y = 1000 - y; |
y = 1000 - y; |
if (tk_perl) { |
if (tk_perl) { |
Line 383 $cmy * %d / 1000, \ |
|
Line 381 $cmy * %d / 1000, \ |
|
(defined $font ? (-font => $font) : ()));\n", |
(defined $font ? (-font => $font) : ()));\n", |
x, y, str, tk_colors[tk_color], tk_anchor); |
x, y, str, tk_colors[tk_color], tk_anchor); |
} else { |
} else { |
|
/* Have to quote-protect '[' and ']' characters */ |
|
int i, newsize = 0; |
|
char *quoted_str; |
|
|
|
for (i=0; str[i] != '\0'; i++) { |
|
if ((str[i] == '[') || (str[i] == ']')) |
|
newsize++; |
|
newsize++; |
|
} |
|
quoted_str = gp_alloc(newsize + 1, "TK_put_text: quoted string"); |
|
|
|
for (i=0, newsize = 0; str[i] != '\0'; i++) { |
|
if ((str[i] == '[') || (str[i] == ']')) |
|
quoted_str[newsize++] = '\\'; |
|
quoted_str[newsize++] = str[i]; |
|
} |
|
quoted_str[newsize] = '\0'; |
fprintf(gpoutfile,"\ |
fprintf(gpoutfile,"\ |
eval $can create text \ |
eval $can create text \ |
[expr $cmx * %d /1000] \ |
[expr $cmx * %d /1000] \ |
[expr $cmy * %d /1000] \ |
[expr $cmy * %d /1000] \ |
-text \\{%s\\} -fill %s -anchor %s\ |
-text \\{%s\\} -fill %s -anchor %s\ |
[expr [info exists font]?\"-font \\$font\":{}]\n", |
[expr [info exists font]?\"-font \\$font\":{}]\n", |
x, y, str, tk_colors[tk_color], tk_anchor); |
x, y, quoted_str, tk_colors[tk_color], tk_anchor); |
|
free(quoted_str); |
} |
} |
} |
} |
|
|
Line 608 START_HELP(tkcanvas) |
|
Line 624 START_HELP(tkcanvas) |
|
"", |
"", |
" use Tk;", |
" use Tk;", |
" my $top = MainWindow->new;", |
" my $top = MainWindow->new;", |
" my $c = $top->Canvas;", |
" my $c = $top->Canvas->pack;", |
" $c->pack();", |
" my $gnuplot = do \"plot.pl\";", |
" do \"plot.pl\";", |
" $gnuplot->($c);", |
" gnuplot->($c);", |
|
" MainLoop;", |
" MainLoop;", |
"", |
"", |
" The code generated by `gnuplot` creates a procedure called \"gnuplot\"", |
" The code generated by `gnuplot` creates a procedure called \"gnuplot\"", |