home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
stazsoftware.com
/
www.stazsoftware.com.tar
/
www.stazsoftware.com
/
futurebasic
/
sample-code
/
SwitchingToFB.sit
/
storage_bin
/
Print.incl
< prev
next >
Wrap
Text File
|
2002-07-31
|
3KB
|
158 lines
/*
These routines assume that all cells are of equal width
calculated from the constant _colCount in the .glbl file.
All print routines assume that the printer is already
selected (ROUTE _toPrinter).
*/
/*
calc the rectangle for any cell
*/
LOCAL FN calcCellRect(row,col,@rPtr AS ^RECT)
'~';
DIM r AS RECT
DIM ht,wd
col --
row --
ht = USR FONTHEIGHT + 2
r.top = row * ht
r.bottom = r.top + ht
wd = WINDOW(_width)\\_colCount
r.left = col * wd
r.right = r.left + wd
BLOCKMOVE @r,rPtr,SIZEOF(RECT)
END FN
/*
print the cell. if doFrame is non-zero
put a line along the bottom and righthand
borders
*/
LOCAL FN printCell(row,col,cellText AS STR255,doFrame AS BOOLEAN)
'~';
DIM r AS RECT
FN calcCellRect(row,col,r)
DEF LBOX(r,cellText)
LONG IF doFrame
MOVETO (r.left , r.top )
LINETO (r.right - 1, r.top )
MOVETO (r.left , r.bottom - 1)
LINETO (r.right - 1, r.bottom - 1)
END IF
END FN
/*
it's just a heading
*/
LOCAL FN printHeading(pageNumber)
'~';
DIM r AS RECT
DIM err
DIM title AS STR255
err = FN USETHEMEFONT(_kThemeEmphasizedSystemFont,_smSystemScript)
SETRECT(r,0,0,WINDOW(_width),USR FONTHEIGHT)
title = gPref.reportTitle
LONG IF gPref.titleInfoFlags AND _includeDateMask
title += SPACE$(25) + DATE$
END IF
LONG IF gPref.titleInfoFlags AND _includePageNumber
title += SPACE$(25) + "Page " + STR$(pageNumber)
END IF
DEF CBOX(r,title)
FN printCell(2,1,"Name" ,_zTrue)
FN printCell(2,2,"Address" ,_zTrue)
FN printCell(2,3,"City, State ZIP",_zTrue)
FN printCell(2,4,"Phone" ,_zTrue)
err = FN USETHEMEFONT(_kThemeApplicationFont,_smSystemScript)
END FN = USR FONTHEIGHT * 2
/*
let 'er rip, 'tater chip
*/
LOCAL FN printReport
'~';
DIM t AS STR255
DIM count AS LONG
DIM @fileRef AS LONG
DIM @recNum AS LONG
DIM row,pageNumber,pixelPos,ht,err
DEF LPRINT
IF PRCANCEL THEN EXIT FN
LONG IF FN getRefNums(fileRef,recNum) = _noErr
count = FN countRecords
FN saveCurrentRecord
pageNumber = 0
row = 1000
'~'6
ROUTE _toPrinter
err = FN USETHEMEFONT(_kThemeApplicationFont,_smSystemScript)
ht = USR FONTHEIGHT + 2
count --
FOR recNum = 0 TO count
LONG IF row + 1 * ht > WINDOW(_height)
LONG IF pageNumber
ROUTE _toScreen
CLEAR LPRINT
ROUTE _toPrinter
END IF
pageNumber ++
FN printHeading(pageNumber)
row = 3
END IF
RECORD #fileRef,recNum
READ #fileRef,gStorageBin
LONG IF gStorageBin.lastName <> "** Blank Record **"
//name
t = gStorageBin.firstName + " " + gStorageBin.lastName
FN printCell(row,1,t,_false)
// street address
t = gStorageBin.address1
LONG IF LEN(gStorageBin.address2)
t += ", " + gStorageBin.address2
END IF
FN printCell(row,2,t,_false)
// city, state, zip
t = gStorageBin.city + ", " + gStorageBin.state
t += " " + gStorageBin.zip
FN printCell(row,3,t,_false)
// phone
t = gStorageBin.phone
FN printCell(row,4,t,_false)
row ++
END IF
NEXT recNum
ROUTE _toScreen
CLOSE LPRINT
'~'6
END IF
END FN