home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
dbase
/
printer
/
postscri
/
ps_lib.prg
next >
Wrap
Text File
|
1991-02-26
|
11KB
|
294 lines
* Program........: PS_Lib.PRG
* Version........: 0.2
* Author.........: Richard Elliott, Ferret Software
* Copyright......: Copyright 1991, Ferret Software, All Rights reserved
* Purpose........: Postscript Procedure Library
* Language.......: Foxpro 1.02
* Usage..........: SET PROCEDURE TO PS_Lib
* ---------------------------------------------------------
PROCEDURE Init_Print && Do first to set system variables
PUBLIC TMargin, LMargin, xpos, ypos, crlf, ejectit, psfooter
TMargin = 1 && default margins in inches, change as needed
LMargin = 1
xpos = 0
ypos = 11
crlf = CHR(13) + CHR(10) && Used to make PS code readable in file
ejectit = "showpage" + crlf && Use as: ??? ejectit - For new pages
psfooter = "%!END" + crlf + "" && Clears up the end
??? "%!PS-Adobe-1.0" + crlf && Standard PS header info
??? "%%Title: PS_LIB output" + crlf
??? "%%Creator: Ferret Software's PS Library" + crlf
??? "%%CreationDate: " + DTOC(DATE()) + crlf
??? "%%EndComments" + crlf + crlf
RETURN
* ---------------------------------------------------------
FUNCTION Orient
PARAMETERS _orient
** Use as: ??? ORIENT(orientation)
DO CASE
CASE UPPER( _orient ) = "PORT"
_temp = "0 0 translate 0 rotate" + crlf
CASE UPPER( _orient ) = "LAND"
_temp = "11 0 translate 90 rotate" + crlf
OTHERWISE
_temp = ''
ENDCASE
RETURN _temp
* ---------------------------------------------------------
FUNCTION Lpi
PARAMETERS lpi_num
** Use as: ??? LPI( lpi_number )
** Defines /newline with
line_size = STR(72/lpi_num,2,2)
??? "/newline"
??? " {/ypos ypos &line_size sub def"
??? " 0 xpos ypos moveto} def"
RETURN ''
* ---------------------------------------------------------
FUNCTION FontPick
PARAMETERS _font_, _size_
** Use as: ??? FONTPICK(font_name, font_point_size)
** Other fonts will be added later
points = ALLTRIM(STR(_size_,5,1))
DO CASE
CASE _font_ = "HEN"
_temp = "/Helvetica findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HEO"
_temp = "/Helvetica-Oblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HEB"
_temp = "/Helvetica-Bold findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HEX"
_temp = "/Helvetica-BoldOblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "TRN"
_temp = "/Times-Roman findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "TRI"
_temp = "/Times-Italic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "TRB"
_temp = "/Times-Bold findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "TRX"
_temp = "/Times-BoldItalic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "CRN"
_temp = "/Courier findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "CRO"
_temp = "/Courier-Oblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "CRB"
_temp = "/Courier-Bold findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "CRX"
_temp = "/Courier-BoldOblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "AGN"
_temp = "/AvantGarde-Book findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "AGO"
_temp = "/AvantGarde-BookOblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "AGD"
_temp = "/AvantGarde-Demi findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "AGX"
_temp = "/AvantGarde-DemiOblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "BKL"
_temp = "/Bookman-Light findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "BKI"
_temp = "/Bookman-LightItalic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "BKD"
_temp = "/Bookman-Demi findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "BKX"
_temp = "/Bookman-DemiItalic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HNN"
_temp = "/Helvetica-Narrow findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HNO"
_temp = "/Helvetica-Narrow-Oblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HNB"
_temp = "/Helvetica-Narrow-Bold findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "HNX"
_temp = "/Helvetica-Narrow-BoldOblique findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "NCN"
_temp = "/NewCenturySchlbk-Roman findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "NCI"
_temp = "/NewCenturySchlbk-Italic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "NCB"
_temp = "/NewCenturySchlbk-Bold findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "NCX"
_temp = "/NewCenturySchlbk-BoldItalic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "PAN"
_temp = "/Palatino-Roman findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "PAI"
_temp = "/Palatino-Italic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "PAB"
_temp = "/Palatino-Bold findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "PAX"
_temp = "/Palatino-BoldItalic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "ZCM"
_temp = "/ZapfChancery-MediumItalic findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "ZAD"
_temp = "/ZapfDingbats findfont " + points + " scalefont setfont" + crlf
CASE _font_ = "SYM"
_temp = "/Symbol findfont " + points + " scalefont setfont" + crlf
OTHERWISE
_temp = ''
ENDCASE
RETURN _temp
* ---------------------------------------------------------
FUNCTION SayIt
PARAMETERS _down , _over , _text, _pict
** Use as: ??? SayIt(inches_down, inches_over, info_print)
** ALL non-character is now handled without prior conversion
** Number data is RIGHT JUSTIFIED at _down, _over place
_type = TYPE("_text")
DO CASE
CASE _type = "C" .OR. _type = "D" .OR. _type = "L"
DO CASE
CASE _type = "D"
_text = DTOC( _text )
CASE _type = "L"
IF _text
_text = "Y"
ELSE
_text = "N"
ENDIF
ENDCASE
_down = ( _down - TMargin )*72
_over = ( _over + LMargin )*72
mypos = STR( _down, 4 )
mxpos = STR( _over, 4 )
_temp = mxpos + " " + mypos + " moveto" + crlf
_temp = _temp + "(" + _text + ") show" + crlf
CASE _type = "N"
_temp = LTRIM(TRANSFORM( _text, _pict ))
_down = ( _down - TMargin )*72
_over = ( _over + LMargin )*72
mypos = STR( _down, 4 )
mxpos = STR( _over, 4 )
_temp = "(" + _temp + ")" + " dup stringwidth pop"
_temp = _temp + " " + mxpos + " exch sub"
_temp = _temp + " " + mypos + " moveto show" + crlf
OTHERWISE
_temp = ''
ENDCASE
RETURN _temp
* ---------------------------------------------------------
FUNCTION SetGray
PARAMETERS _gray
** Use as ??? SETGRAY(percent_white)
** 0 = Black, 1 = white, .01 - .99 = gray shades
** This also impacts the fonts and line/box drawing
gray_ = ALLTRIM(STR( _gray, 4,2 ))
_temp = gray_ + " setgray" + crlf
RETURN _temp
* ---------------------------------------------------------
FUNCTION LineDraw
PARAMETERS _sline , _scol ,_eline , _ecol , _thick
** Use as: ??? LINEDRAW(start_line, start_column, end_line,
** end_column, thickness)
** Line and column numbers are in inches
** Thickness is times 1/72 inch
sline_ = STR(( 72 * ( _sline - TMargin )) , 4 )
scol_ = STR(( 72 * ( _scol + LMargin )) , 4 )
eline_ = STR(( 72 * ( _eline - TMargin )) , 4 )
ecol_ = STR(( 72 * ( _ecol + LMargin )) , 4 )
thick_ = STR( _thick , 4 )
_temp = "newpath" + crlf
_temp = _temp + " " + scol_ + " " + sline_ + " moveto" + crlf
_temp = _temp + " " + ecol_ + " " + eline_ + " lineto" + crlf
_temp = _temp + " " + thick_ + " " + " setlinewidth" + crlf
_temp = _temp + "stroke" + crlf
RETURN _temp
* ---------------------------------------------------------
FUNCTION BoxDraw
PARAMETERS _sline , _scol ,_width , _height , _thick
** Use as: ??? BOXDRAW(start_line, start_column, width, height, thickness)
** Line, column, width and height numbers are in inches
** Thickness is times 1/72 inch
sline_ = STR(( 72 * ( _sline - TMargin )) , 4 )
scol_ = STR(( 72 * ( _scol + LMargin )) , 4 )
width_ = STR(( 72 * ( _width )) , 4 )
height_ = STR(( 72 * ( _height )) , 4 )
thick_ = STR( _thick , 4 )
_temp = "newpath" + crlf
_temp = _temp + " " + scol_ + " " + sline_ + " moveto" + crlf
_temp = _temp + " " + RIGHT( width_, 4) + " 0" + " rlineto" + crlf
_temp = _temp + " " + " 0 " + SPACE(4-LEN(ALLTRIM( height_ ))-1) + ;
"-" + ALLTRIM(height_) + " rlineto" + crlf
_temp = _temp + " " + SPACE(4-LEN(ALLTRIM( width_ ))-1) +"-"+ ;
ALLTRIM( width_ ) + " 0 rlineto " + crlf
_temp = _temp + " " + "closepath" + crlf
_temp = _temp + " " + thick_ + " setlinewidth" + crlf
_temp = _temp + "stroke" + crlf
RETURN _temp
* ---------------------------------------------------------
FUNCTION BoxShade
PARAMETERS _sline , _scol ,_width , _height , _gray
** Use as: ??? BOXSHADE(start_line, start_column, width, height,
** percent_gray)
** Line, column, width and height numbers are in inches
** Gray percent is based on white = 100% = 1.0, 50% = .50, etc.
sline_ = STR(( 72 * ( _sline - TMargin )) , 4 )
scol_ = STR(( 72 * ( _scol + LMargin )) , 4 )
width_ = STR(( 72 * ( _width )) , 4 )
height_ = STR(( 72 * ( _height )) , 4 )
gray_ = STR( _gray , 4, 2 )
_temp = "newpath" + crlf
_temp = _temp + " gsave" + crlf
_temp = _temp + " " + scol_ + " " + sline_ + " moveto" + crlf
_temp = _temp + " " + RIGHT(width_,4) + " 0 rlineto" + crlf
_temp = _temp + " 0 " + SPACE(4-LEN(ALLTRIM(height_))-1) + "-"+ ;
ALLTRIM(height_) + " rlineto" + crlf
_temp = _temp + " " + SPACE(4-LEN(ALLTRIM(width_))-1) + "-" + ;
ALLTRIM(width_) + " 0 rlineto" + crlf
_temp = _temp + " closepath" + crlf
_temp = _temp + " " + gray_ + " setgray" + crlf
_temp = _temp + " fill" + crlf
_temp = _temp + " grestore" + crlf
RETURN _temp
* ---------------------------------------------------------
* EOF: PS_LIB.PRG