/* add a header or footer to a window or worksheet */
texttitler(title, justify, color, target, tfont, marg, tagstr)
{
local loc, oh, nh = 0;
if (argc < 7)
{
if (argc < 6)
{
if (argc < 5)
{
if (argc < 4)
{
if (argc < 3)
{
if (argc < 2)
{
if (argc < 1) error("texttitler - title string required");
/* center */
justify = 0;
}
color = -1;
}
/* window */
target = 3;
}
tfont = WINTITLE_FONT;
}
just = 0;
}
tagstr = "";
}
/* justify to location */
loc = _just2loc(justify, marg);
/* find previous title */
if (target != GLASS_WSMARGIN)
{
/* window text */
oh = findtext("winnum", getwnum, "target", target, "font", tfont, "margin", marg, "location", loc, "tag", tagstr);
}
else
{
/* worksheet text */
oh = findtext("target", target, "font", tfont, "margin", marg, "location", loc, "tag", tagstr);
}
/* add text to target */
nh = text(0.0, 0.0, target, color, -2, tfont, -2, -2, -2, marg, -2, -2, -2, -2, -2, -2, -2,
-2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, loc, caststring(title));
/* remove previous */
if (length(oh) > 0)
{
if (isunspecified(nh))
{
/* modify existing */
oh.text = title;
oh.fg = color;
oh.font = tfont;
oh.margin = marg;
oh.location = loc;
}
else
{
deletehandle(oh);
}
}
if (not(isunspecified(nh)))
{
nh.tag = caststring(tagstr);
}
}