GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEXT::GRAPHICS (3)

.ds Aq ’

NAME

Text::Graphics -- A text graphics rendering toolkit

CONTENTS

DESCRIPTION

This is a toolkit for rendering plain text via an API like that used for graphics rendering in GUI toolkits. This package might be used when you want to do sophisticated rendering of plain text, e.g., for graphing, creating of complex forms for email and fax, and so on.

SYNOPSIS



 use Text::Graphics;
 my $text = "A text graphics rendering toolkit.\n";
 my $page = Text::Graphics::Page->new( 20, 10);
 my $panel0 = Text::Graphics::BorderedPanel->new( 20, 10);
 my $panel1 =
  Text::Graphics::FilledBorderedTextPanel->new($text x 3, 25, 12);
 $panel0->setBackground("#");
 $panel1->setBackground(" ");
 $page->add($panel0);
 $page->add($panel1, 5, 2);
 $page->render();

 +-------------------+
 |###################|
 |####+--------------+
 |####|A text graphic|
 |####|rendering tool|
 |####|text graphics |
 |####|toolkit. A tex|
 |####|graphics rende|
 |####|toolkit.      |
 |####|              |
 +----+--------------+



User API

CWText::Graphics::Page

Class to represent a page.
new (width, height) Construct a new page with the specified width and height.
add (Panel, x_offset, y_offset) Add a Panel at the specified offset.
render ( [ scalar_reference ] ) Render the page. If an argument is given, it is assumed to be a SCALAR REFERENCE, and rendering will be done to such reference. e.g., if you want to render to $buf, you might do



 $w->render(\ $buf);



If no argument to render() is provided, then rendering is simply done to STDOUT using print.

CWText::Graphics::Panel

Class to represent a panel.
new (width, height) Construct a new panel with the specified width and height.
add (Panel, x_offset, y_offset) Add a Panel at the specified offset. This child panel is contained within its parent and will not extend beyond the parents boundaries.
setBackground ( background ) Set the background on the panel to the specified char.
getSize () Get the size of a panel. This method is a hook for layout managers. E.g., If you set up a wrapped text panel with height 0, then call getSize(), then it will return the same width but the new desired height. (If you are interested in how to write a layout manager on top of this code, please contact me (SF) as I have done so but have not released it.)
setSize (width, height) Set the size of a panel. This method is a hook for layout managers.
getOffset () get the offset of a panel. This method is a hook for layout managers.
setOffset (x_offset, y_offset) set the offset of a panel. This method is a hook for layout managers.

Subclassing

Most of the work you might do with this module will be by subclassing panel. The idea is you make a new panel, like LinePanel, that has a constructor setting character to draw and the start and end coordinates for the line. Then, in the LinePanels _drawSelf(gc) routine, it calls on the gc to draw a line:



 package LinePanel;
 use vars qw (@ISA);
 @ISA = qw (Panel);

 sub new {
  my $this = {};
  bless $this, shift;
  $this->{char} = shift;
  $this->{startx} = shift;
  $this->{starty} = shift;
  $this->{endx} = shift;
  $this->{endy} = shift;
  return $this;
 }

 sub _drawSelf {
  my $this = shift;
  my $gc = shift;

  $gc->drawLine($this->{char},
                $this->{startx}, $this->{starty},
                $this->{endx}, $this->{endy});

 }



There are some other subclasses included, particularly those for text handling.

Actually the drawLine() method for the GraphicsContext is not included b/c I just do not need it, though I have a mostly working version if anyone is interested (it is not complicated =).

GraphicsContext does include the following methods, however:
drawBorder(x_offset, y_offset, width, height) Draw a border with the specified coordinates.
fillRect(char, x_offset, y_offset, width, height) Fill the specified rectangle with the specified character. Note that filling with is a good way to get an opaque panel.
drawString(string, x_offset, y_offset) Draw the specified string at the specified offset. If you want to control the width then you probably want to look at FilledTextPanel.

AUTHORS



 Stephen Farrell <stephen@farrell.org>
 Jeremy Mayes



POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 717: ’=item’ outside of any ’=over’
Around line 737: You forgot a ’=back’ before ’=head2’
Around line 741: ’=item’ outside of any ’=over’
Around line 776: You forgot a ’=back’ before ’=head1’
Around line 819: ’=item’ outside of any ’=over’
Around line 835: You forgot a ’=back’ before ’=head1’
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEXT::GRAPHICS (3) 2016-03-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.