home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / auto / Tk / Ghostscript / StartInterp.al < prev    next >
Encoding:
Text File  |  1997-08-10  |  1.2 KB  |  34 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Ghostscript.pm.  Changes made here will be lost.
  2. package Tk::Ghostscript;
  3.  
  4. sub StartInterp
  5. {
  6.  my $w = shift;
  7.  $w->StopInterp;
  8.  $w->idletasks;
  9.  $w->MakeWindowExist;
  10.  my $win  = ${$w->WindowId};  # Window for properties/events
  11.  my $dest = ${$w->WindowId};  # Xid of drawable to draw on (gs3 and later)
  12.  $ENV{'GHOSTVIEW'} = sprintf("%d %d",$win,$dest);
  13.  $w->property('set','GHOSTVIEW','STRING',8,
  14.               sprintf("%d %d %d %d %d %d %g %g %d %d %d %d",
  15.                $w->{'bpixmap'},
  16.                $w->{'page_orientation'},
  17.                @{$w->{'BoundingBox'}},
  18.                $w->{'x_pixels_per_inch'}, $w->{'y_pixels_per_inch'},
  19.                @{$w->{'Margins'}}));
  20.  my $screen = $w->Screen;
  21. # my $bg = $screen->WhitePixelOfScreen;
  22. # my $fg = $screen->BlackPixelOfScreen;
  23. # $w->property('set','GHOSTVIEW_COLORS','STRING',8,sprintf("Monochrome %d %d",$fg,$bg));
  24.  $w->{'Pending'} = [];
  25.  $w->XSync(0);
  26.  my $fh = $w->{'FH'};
  27.  $w->{'pid'} = open($fh,"| gs -sDEVICE=x11 -dQUIET -dNOPAUSE -");
  28.  my $fl = fcntl($fh,F_GETFL,0);
  29.  die "Cannot F_GETFL:$!" unless (defined $fl);
  30.  fcntl($fh,F_SETFL,$fl | O_NONBLOCK) || die "Cannot F_SETFL:$!";
  31. }
  32.  
  33. 1;
  34.