|
HTML::TableLayout - Layout Manager for cgi-based web applications |
HTML::TableLayout - Layout Manager for cgi-based web applications
This is a HTML-generating package for making graphical user interfaces via a web browser using a ``Layout Manager'' paradigm such as in Tk/Tcl or Java. It includes a component heirarchy for making new ``widgets''.
parameters window table cell header text image link list pre
form choice button hidden input_text password submit radio
use HTML::TableLayout;
$w = window(undef,"Hello World");
$w->insert(table()->insert("hello world"));
# ...
$w->print();
This documentation is incomplete and occassionally wrong. As always, the source is the best reference (and, in fact, is relatively well commented in this case). This documentation will improve as the API stabilizes.
On the other hand, some effort was made to bring it up-to-date with release 1.1.4.
I thought that ``new'' was too noisy and took up too much space, so I do not use it in the API. When you call, for example,
window($x,$y,$z),
you are really doing
HTML::TableLayout::Window->new($x,$y,$z).
(but isn't it a whole lot nicer looking?)
parameters
$p->set($obj, %p); # destructive
$p->insert($obj, %p); # non-destructive
$p->delete(@tags);
Where the $obj is any instance of any component.
The hash %p is a hash of parameters. In all but a few cases these parameters are passed directly through as HTML parameters. E.g., if I write
$p->set(table(),width=>``100%'',border=>undef,foo=>``bar''),
then all tables will look like
<TABLE width=``100%'' border foo=``bar''>
(plus other parameters you add later). Note that it blindly passes through what is presumably a meaningless HTML flag--``foo''.
Now, you might find the first argument (an instance of the object) passed in a little odd, to say the least. Once you pass in any instance of any object, it ``recognizes'' that kind of object in the future. This way, it works not only for built-in classes, but also any that you choose to derive yourself. (NOTE: this will change w/1.2.x, but it will probably still work this way for backwards compatibility)
One place that this is very useful is a trivial case. Let's say that I want to define a focused table--i.e., a table that I use consistently to guide the users attention. I can make a class like such:
package FocusedTable;
@ISA=qw(HTML::TableLayout::ComponentTable);
## EOF
and then I can add a setting:
$p->set(FocusedTable->new(), %focustable_settings);
Now, whenever you use a FocusedTable, it will use these settings, even though in reality it is the same as a table.
Hmm... you're thinking, but what if I derive a special Checkbox, but I
want it to get the parameters for a regular checkbox. I've provided
for this as well. In your constructor for this new checkbox (or an
init() method):
package myCheckbox;
@ISA=qw(HTML::TableLayout::FormComponent::Checkbox);
sub new {
my ($class, %params) = @_;
my = {};
bless , $class;
->tl_inheritParamsFrom(checkbox());
return ;
}
And the mechanism that sets the parameters will think it is really just a Checkbox.
(It might be nice if instead of having to set this explicitely, the
mechanism (_obj2tag(), actually) could check based upon inheritance
and use the settings from the closest parent. The thing is (a) I
don't know how to do this efficiently (b) I want to have this
tl_inheritParamsFrom() anyway so that one can force whichever behavior
she wants.)
NOTE: This is one of the things that will probably change/improve for version 1.2.x...
window
window($parameters, $title, %params)
win_header
win_header(2,"some text")
will produce:
<H2>some text</H2>
Similarly,
win_header(undef,"some text")
will produce
some text
but will place it up at the top of the window.
table
$t=table(columns=>15);
This parameter is passed directly out to the HTML, but this layout manager also pays attention to it internally.
Tables have one external method:
$t->insert($some_component);
This something can be pretty much anything derived from HTML::TableLayout::Component. It can also be a form--as a general rule the table just does the right thing with whatever you stick in it. If it does not, it is a bug (please let me know!)
cellcell_headertext
$c->insert(text($text,%params));
The parameters are a bit special--if you put in stuff like bold=>undef or size=>``+2'', then it will do the following:
<FONT size=+2><b>whatever</b></FONT>
Like everything else here, this is supposed to ``just work'' as you expect it to, so I had to do some funky translations of HTML tags since HTML is pretty screwed up with this stuff.
image
$c->insert(image($url,%params));
Where the url can be relative or absolute (straight HTML story).
link
$c->insert(link($url,$anchor,%params));
Note that $anchor might be something interesting, like an image, so:
$c->insert(link("whatever.html",image("image.gif")));
should work like a charm.
list
$l=list($numbered, $delimited);
$l->insert("first element");
$l->insert(text("second element",bold=>undef));
$l->insert(link($url,"third element"));
prescriptNOTE there are other classes... see the source for now to find these.
See comments in code, particular TODO in TLCore.pm
Stephen Farrell <stephen@farrell.org>--feel free to write email with any questions.
|
HTML::TableLayout - Layout Manager for cgi-based web applications |