PostScript::Report::Role::Component - Something that can be drawn
This document describes version 0.10 of PostScript::Report::Role::Component, released May 4, 2013 as part of PostScript-Report version 0.12.
This role describes an object that knows how to draw itself on a report. A Component that contains other Components is a Container.
These attributes control the component's formatting. To avoid having to set all of them on every component, their values are inherited much like CSS styles are inherited in HTML. If a component does not have an explicit value set, then the value is inherited from the parent. The inheritance may bubble up all the way to the Report object, which will always provide a default value.
All dimensions are in points.
This controls text alignment.
It may be
This is the background color for the Component.
The color is a number in the range 0 to 1 (where 0 is black and 1 is white) for a grey background,
or an arrayref of three numbers
Blue ] where each number is in the range 0 to 1.
you can specify an RGB color in the HTML hex triplet form prefixed by
#FF0 for yellow).
Unlike the other formatting attributes, its value is not actually inherited, but since a Container draws the background for all its Components, the effect is the same.
This is the border style. It may be 1 for a solid border or 0 for no border. In addition, you may specify any combination of the letters T, B, L, and R (meaning top, bottom, left, and right) to have a border only on the specified side(s).
The thickness of the border is controlled by "line_width".
(Note: The string you give will be converted into the canonical representation, which has the letters upper case and in the order TBLR.)
This is the font used to draw normal text in the Component.
This is the height of the component.
This is the line width. It's used mainly as the border width. A line width of 0 means "as thin as possible".
This is the width of the component. In most cases, you will need to set this explicitly.
The following attributes are not present in all components, but when they are present, they should behave as described here. Attributes whose value can be inherited from the parent are marked (Inherited).
(Inherited) This is the amount of space between the bottom of the component and the baseline of the text inside it. If this is too small, then the descenders (on letters like "p" and "y") will be cut off. (The exact minimum necessary depends on the selected font and size.)
(Inherited) This is the amount of space between the side of the component and the text inside it.
This is the
$value_source that the component will use to retrieve its contents.
See "get_value" in PostScript::Report.
You probably won't need to use this attribute directly.
This attribute contains a reference to the Container or Report that is the direct parent of this Component. It is used for inheritance of attribute values. It is filled in by the "init" method, and you will probably never deal with it directly.
$component->draw($x, $y, $report);
This method draws the component on the current page of the report at position
$y. This method must be provided by the component. The Component role provides a
before draw modifier to draw the component's background.
$component->draw_standard_border($x, $y, $report);
after draw => \&draw_standard_border;
This method (for debugging purposes only) prints a representation of the component to the currently selected filehandle. (Inherited values are not shown.) Note that layout calculations are not done until the report is run, so you will normally see additional
width values after calling "run".
$level (default 0) indicates the level of indentation to use.
The default implementation should be sufficient for most components.
$psID = $component->id;
In order to avoid stepping on each other's PostScript code, any PostScript identifiers created by a component should begin with this string. The default implementation returns the last component of the class name.
The init method of each component is called at the beginning of each report run. The default implementation sets the parent link to enable inheritance of attribute values.
Most components will need to provide an
after modifier to do additional initialization, such as calculating
width. Also, the component should add its standard procedures to
This returns the PostScript::Report object that this Component ultimately belongs to, or
undef if it is not currently owned by a Report. (You should only call this after the
init method has been called.)
The following components are available by default:
This displays a box, which contains a checkmark if the associated value is true.
This is a standard text field.
This is a text field with a label in the corner. It also (optionally) supports multiple lines with word wrap.
This Container draws its children in a horizontal row.
This allows you to include an EPS file.
This is just an empty box for padding.
This Container draws its children in a vertical column.
No bugs have been reported.
Christopher J. Madsen
<perl AT cjmweb.net>
Please report any bugs or feature requests to
<bug-PostScript-Report AT rt.cpan.org> or through the web interface at http://rt.cpan.org/Public/Bug/Report.html?Queue=PostScript-Report.
You can follow or contribute to PostScript-Report's development at http://github.com/madsen/postscript-report.
I'd like to thank Micro Technology Services, Inc. http://www.mitsi.com, who sponsored development of PostScript-Report, and fREW Schmidt, who recommended me for the job. It wouldn't have happened without them.
This software is copyright (c) 2013 by Christopher J. Madsen.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.