d2bf2c | 1997-11-09 | Francesco Chemolli | |
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
d2bf2c | 1997-11-09 | Francesco Chemolli | |
constant cvs_version = "$Id: obox.pike,v 1.6 1997/11/09 18:38:53 grubba Exp $";
|
07bf51 | 1997-08-31 | Peter Bortas | | constant thread_safe=1;
|
ea0143 | 1997-08-03 | Fredrik Noring | | #include <module.h>
|
07bf51 | 1997-08-31 | Peter Bortas | | inherit "module";
|
ea0143 | 1997-08-03 | Fredrik Noring | | inherit "roxenlib";
#define INFO(s) // perror("### %O"+(s))
#define DEBUG(s) perror("### %O\n",(s))
#define FATAL(s) perror("### %O\n"+(s))
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | #define ERROR(a) sprintf("<b><obox> error:</b> %s<br>\n", (a))
|
ea0143 | 1997-08-03 | Fredrik Noring | |
|
5458ff | 1997-08-23 | Henrik Grubbström (Grubba) | | constant unit_gif = "/internal-roxen-unit";
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | static string img_placeholder (mapping args)
{
int width=((int)args->outlinewidth)||1;
return sprintf("<img src=\"%s\" alt=\"\" width=%d height=%d>",
unit_gif, width, width);
}
static string handle_title(string name, mapping junk_args,
string contents, mapping args)
{
args->title=contents;
return "";
}
static string horiz_line(mapping args)
{
return sprintf("<tr><td colspan=5 bgcolor=\"%s\">\n"
"%s</td></tr>\n",
args->outlinecolor,
img_placeholder(args));
}
static string title(mapping args)
{
if (!args->title)
return horiz_line(args);
string empty=img_placeholder(args);
switch (args->style) {
case "groupbox":
if (!args->left)
args->left="25";
if (args->width && !args->right)
args->right=args->width;
if (!args->right)
args->right="350";
return sprintf("<tr><td colspan=2> </td>\n"
"<td rowspan=3%s> <b>"
"%s%s%s"
"</b></td>\n"
"<td colspan=2> </td></tr>\n"
"<tr%s>"
"<td bgcolor=\"%s\" colspan=2>\n"
"%s</td>\n"
"<td bgcolor=\"%s\" colspan=2>\n"
"%s</td></tr>\n"
"<tr%s><td bgcolor=\"%s\">"
"%s</td>\n"
"<td%s> </td>"
"<td%s> </td>\n"
"<td bgcolor=\"%s\">"
"%s</td></tr>\n"
,
args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "",
args->titlecolor ? "<FONT color=\""+args->titlecolor+"\">" : "",
args->title,
args->titlecolor ? "</FONT>" : "",
args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "",
args->outlinecolor,
empty,
args->outlinecolor,
empty,
args->bgcolor ? " bgcolor=\""+args->bgcolor+"\"" : "",
args->outlinecolor,
empty,
" width="+args->left,
" width="+args->right,
args->outlinecolor,
empty);
case "caption":
return sprintf("<TR bgcolor=%s>"
"<TD>%s</TD>"
"<TD%s> </TD>"
"<TD>%s%s%s</TD>"
"<TD%s> </TD>"
"<TD>%s</TD></TR>",
args->outlinecolor,
empty,
(args->left ? " width="+args->left : ""),
args->titlecolor ? "<FONT color=\""+args->titlecolor+"\">" : "",
args->title,
args->titlecolor ? "</FONT>" : "",
(args->right ? " width="+args->right : ""),
empty);
}
}
|
ea0143 | 1997-08-03 | Fredrik Noring | | string container_obox(string name, mapping args,
string contents, object request_id)
{
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | string s;
|
ea0143 | 1997-08-03 | Fredrik Noring | |
if (args->help) {
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | args->right = 250;
args->title = "The Outlined Box container tag";
|
ea0143 | 1997-08-03 | Fredrik Noring | | contents = "Usage:<p>"
"<<b>obox</b> <b>title</b>=\"Sample title\">"
"<br>Anything, html, text, ...<br>"
"<<b>/obox</b>><p>\n"
|
c2e9ea | 1997-10-27 | Francesco Chemolli | | "Options:<p>\n\n"
|
ea0143 | 1997-08-03 | Fredrik Noring | | "<b>left</b>: Length of line on the left side of the title<br>\n"
"<b>right</b>: Length of line on the right side of to the title<br>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<i>Notice</i> that left and right arguments are constrained by the "
"width argument, if specified.<br>\n"
|
c2e9ea | 1997-10-27 | Francesco Chemolli | | "<b>spacing</b>: Width of the space inside the box<br>\n"
"<b>titlecolor</b>: Color of the title of the box<br>\n"
"<b>outlinecolor</b>: Color of the outline<br>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<b>outlinewidth</b>: Width (in pixels) of the outline<br>\n"
|
c2e9ea | 1997-10-27 | Francesco Chemolli | | "<b>bgcolor</b>: Color of the background and title label<br>\n"
"<b>textcolor</b>: Color of the text inside the box<br>\n"
"<b>align</b>: How to align the box (left|right)<br>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "<b>width</b>: width of the generated box<br>\n"
"<b>style=<caption|groupbox></b>: "
"style of the generated box. "
"(<i>default: groupbox</i>)<br>\n"
"<p>\n\n"
"If the title is not specified in the argument list,<br>"
"you can put it inside the box text, in a <TITLE> "
"HTML container,<br>should it be needed for HTML clarity.<br>";
}
args->outlinecolor = args->outlinecolor || "#000000";
args->style = args->style || "groupbox";
if (!args->title) {
contents=parse_html(contents,([]),(["title":handle_title,]),args);
|
ea0143 | 1997-08-03 | Fredrik Noring | | }
switch (name) {
case "obox":
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | s = "<table border=0 cellpadding=0 cellspacing=0" +
(args->align?" align="+args->align:"") +
(args->width?" width="+args->width:"") + ">\n" +
title(args) +
"<tr" +
(args->bgcolor?" bgcolor="+args->bgcolor:"") +
"><td bgcolor=\"" + args->outlinecolor + "\">" +
img_placeholder(args) + "</td>\n"
"<td colspan=3>\n"
"<table border=0 cellspacing=5 "+
(args->spacing?"width="+(string)args->spacing+" ":"")+">"
"<tr><td>\n";
if (args->textcolor) {
s += "<font color=\""+args->textcolor+"\">" + contents + "</font>";
|
c2e9ea | 1997-10-27 | Francesco Chemolli | | } else {
s += contents;
}
|
ea0143 | 1997-08-03 | Fredrik Noring | |
s += "</td></tr></table>\n"
|
d2bf2c | 1997-11-09 | Francesco Chemolli | | "</td><td bgcolor=\"" + args->outlinecolor + "\">" +
img_placeholder(args) + "</td></tr>\n" +
horiz_line(args) + "</table>\n";
|
ea0143 | 1997-08-03 | Fredrik Noring | | break;
}
return s;
}
array register_module()
{
return ({
|
5458ff | 1997-08-23 | Henrik Grubbström (Grubba) | | MODULE_PARSER,
|
ea0143 | 1997-08-03 | Fredrik Noring | | "Outlined box",
"This is a container tag making outlined boxes.<br>"
"<obox help></obox> gives help.",
0, 1 });
}
mapping query_container_callers()
{
return ([ "obox":container_obox, ]);
}
|