NPRG - generate reports to graphic output devices
use Wingraph; use NPRG; $dc=new Wingraph(device=>'PS', desc=>'Desc' [, metafile=>'metafilename'); $rp=new NPRG(dc=>$dc); $rp->{'atbreak'}=sub {...} $rp->{'beforebeak'}=sub {...} $rp->pushq({...},{...}...{...}); $rp->flushq();
This module allow you generate reports to graphic outpus deviceses using objects like Wingraph. The $dc object must have methods, described in Wingraph documentation.
$dc
NPRG methods
new
Create new NPRG object. Parameter passed by hash, allowed: dc and footerh. The dc is object like Wingrpah. Description of footerh see below.
dc
footerh
Allows you set up callback to proceed page breaking, after page eject. To function passed only one parameter - the report object itself.
Like 'atbreak', but only before page eject. You can reserve page space for footer by creating report object with footerh parameter - the footerh virtual points will be reserved and every page for footer.
'atbreak'
The pushq functions is core of NPRG. At every call of pushq the report data pushed into report queue, and at every call of flushq() data flushed. If no enough space in page then page ejected, calling the NextPage method of $dc object. Data, pushed together between flushq calls cannot be splitted between pages. Data passed as array of references to hashes, where every hash described a column, and this columns will be equal high and placed from the left to the right in order when they appear in pushq call. For example, call
pushq
flushq()
give the something like
and so on. You can use following hash pairs in column hashes:
begin text
optional. Specifies font for data in format, understanding by $dc object, <code>'Courier, 12, 0'</code> for example.
required. Width of column in vitrual points.
optional. Value to display. If value is scalar then corresponding string is displayed. If value is reference to sub, then this sub will be called. In addition to decribed here params new params $dc, xpos, ypos, 'height', width, compute will be passed. xpos, ypos defines the coordinates of top left corner of bounding rectangle, width and height defines width and height. If parameter compute is defined then sub must return minimal requred height of rectangle, if not - display the data. See drawmatrix sub for detail and as example.
value
xpos
ypos
'height'
width
compute
height
drawmatrix
optional. Define a border around displayed data. Must be string with T, B, L, R chars for border on top, bottom, left and right side of bounding rectangle. Default is empty string.
T
B
L
R
optional. Define width of pen of border. Default =1.
optional. Define the brush to fill background. If not defined then background is not filled.
optional. Define the style used to display data. Must be string of chars. Horizontal alignment:
Text is centered
Text is left-ajusted
Text is right-ajusted
Text is justified
Vertical alignment:
Text is vertical cenetered
Text is bottom alignment
Text is top alignment
Minimail height of displayed data
end text
drawmatrix sub allow to display structured data into one cell of report. drawmatrix use matrix hash key, which is a reference to array of references to array of references to hashes:
matrix
Size of each cell in displayed matrix is 1/n of total width, where n is a number of columns in matrix row.
It's all, folks!
2 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head2'
Non-ASCII character seen before =encoding in 'value=>'Îò÷åò'. Assuming CP1252
To install NPRG, copy and paste the appropriate command in to your terminal.
cpanm
cpanm NPRG
CPAN shell
perl -MCPAN -e shell install NPRG
For more information on module installation, please visit the detailed CPAN module installation guide.