#! /usr/local/bin/tclsh 
#==========================================================================
# Feature testing program for TclVSrpt v1.0
#
# Copyright (c) 1995, Steven B. Wahl
# See the file "license.terms" for information on usage and
# redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#==========================================================================
if {[file exists ./TclVSrpt.tcl]} {
		source ./TclVSrpt.tcl
} else {
	global auto_index
	if {(![info exists auto_index(rptInitialize)]) && \
		    ([info proc rptInitialize] != "rptInitialize")} {
		error "Could not locate TclVSrpt procedures, check installation."
	}
}
puts stdout "testit -- TclVSrpt v1.1 feature test program"
puts -nonewline stdout "Generate (A) ASCII or (P) Postscript output?  "
if {"p" != [string tolower [string index [gets stdin] 0]]} {
	set rtype "ASCII"
	set ofile "testit.txt"
} else {
	set rtype "Postscript"
	set ofile "testit.ps"
}
# -- create the test document

rptInitialize -type $rtype -encoding Standard

rptDefPaper \
		-pagesize letter \
		-orientation portrait \
		-margins 1i

rptDefPage

set text \
"Generally, you may claim head of household filing 
status on your tax return only if you are unmarried and 
pay more than 50% of the costs of keeping up a home 
for yourself and your dependent(s) or other qualifying
individuals."

set tabtext \
"1	Left Tab	Center Tab	Right Tab
2	1 GB SCSI disk	DISK1GB	495.00
3	Additional License	T200	7,995.00
4	Net Revenues	Second Quarter	5,645,332.52"

set alphatest \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 )!@#\$%^&*("

set psfonts "AvanteGarde Bookman Courier Helvetica Helvetica-Narrow \
NewCenturySchlbk Palatino Symbol Times ZapfChancery ZapfDingbats"

# -- Create appropriate text style definitions

rptDefStyle -name title \
	-font Helvetica -size 18 -bold -align center

rptDefStyle -name test  \
	-font Helvetica -size 12 -underline -bold -gap 6p

rptDefStyle -name indent0 \
	-font Times -size 10 -align justified -nowrap
rptDefStyle -name indent1 \
	-font Times -size 10 -align justified -nowrap \
	-leftindent 1i -rightindent 1i
rptDefStyle -name indent1.5  \
	-font Times -size 10 -align justified -nowrap \
	-leftindent 1.5i -rightindent 1.5i

rptDefStyle -name leftalign  \
	-font Times -size 10 -align left -nowrap
rptDefStyle -name rightalign  \
	-font Times -size 10 -align right -nowrap
rptDefStyle -name centeralign  \
	-font Times -size 10 -align center -nowrap

rptDefStyle -name windent0 \
	-font Times -size 10 -align justified -wrap
rptDefStyle -name windent1 \
	-font Times -size 10 -align justified -wrap \
	-leftindent 1i -rightindent 1i
rptDefStyle -name windent1.5  \
	-font Times -size 10 -align justified -wrap \
	-leftindent 1.5i -rightindent 1.5i

rptDefStyle -name wleftalign  \
	-font Times -size 10 -align left -wrap
rptDefStyle -name wrightalign  \
	-font Times -size 10 -align right -wrap
rptDefStyle -name wcenteralign  \
	-font Times -size 10 -align center -wrap

rptDefStyle -name tabtext  \
	-font Times -size 10 -tabs .25i 3ic 5.75ir -tabstyle absolute -nowrap



# -- put out title
rptSetStyle title
rptAddLine "TclVSrpt v1.1 Feature Test Document"
rptNewLine 1

proc testit {style tabs wtest testname text} {
	puts stdout "Executing test:  $testname"
	rptNewPage -guardline 8
	rptSetStyle test
	rptAddLine "$testname"
	rptNewLine 0
	rptSetStyle $style
	if {!$tabs} {
		set lines "[split "$text" \n]"
		set line1 "[lindex $lines 0]"
		set others "[lrange $lines 1 end]"
		rptAddLine "$line1"
		if {$wtest} {
			foreach line $others {
				rptAddText "$line"
			}
		} else {
			foreach line $others {
				rptAddLine "$line"
			}
		}
	} else {
		set lines "[split "$text" \n]"
		foreach line $lines {
			rptAddLine "$line"
			rptNewLine 0
        }
    }
    rptNewLine 2
}

testit indent0 0 0 "no indent, no wrap, justified" "$text"
testit indent1 0 0 "1\" indent, no wrap, justified" "$text"
testit indent1.5 0 0 "1.5\" indent, no wrap, justified" "$text"
testit leftalign 0 0 "left aligned, no wrap" "$text"
testit centeralign 0 0 "center aligned, no wrap" "$text"
testit rightalign 0 0 "right aligned, no wrap" "$text"
testit windent0 0 1 "no indent, wrapped, justified" "$text"
testit windent1 0 1 "1\" indent, wrapped, justified" "$text"
testit windent1.5 0 1 "1.5\" indent, wrapped, justified" "$text"
testit wleftalign 0 1 "left aligned, wrapped" "$text"
testit wcenteralign 0 1 "center aligned, wrapped (expect garbage)" "$text"
testit wrightalign 0 1 "right aligned, wrapped (expect garbage)" "$text"
testit tabtext 1 0 "tab test" "$tabtext"

foreach font $psfonts {
    puts stdout "Executing test:  font test for $font"
    rptSetStyle test
    rptNewPage -guardline 5
    rptAddLine "font test for $font"
    rptNewLine 0
    rptDefStyle -name fonttest -font $font -size 10 -wrap -wrapindent .25i
    rptSetStyle fonttest
    rptAddLine "$alphatest"
    rptNewLine 0
    rptDefStyle -name fonttest -font $font -bold -size 10 -wrap \
        -wrapindent .25i
    rptSetStyle fonttest
    rptAddLine "$alphatest"
    rptNewLine 0
    rptDefStyle -name fonttest -font $font -italic -size 10 -wrap \
        -wrapindent .25i
    rptSetStyle fonttest
    rptAddLine "$alphatest"
    rptNewLine 0
    rptDefStyle -name fonttest -font $font -bold -italic -size 10 -wrap \
        -wrapindent .25i
    rptSetStyle fonttest
    rptAddLine "$alphatest"
    rptNewLine 1
}

puts stdout "Executing Encapsulated Postscript Test..."
rptSetStyle test
rptAddLine "Encapsulated Postscript File Inclusion Test"
rptNewLine 0
rptInclude -when Postscript -eps -epsalign L -file pb46.eps
    
rptDone -f $ofile
puts stdout "Done...results located in \"$ofile\"" 

