View Raw SPL
/* add a header or footer to a window or worksheet */
texttitler(title = 0, justify = 0, color = -1, target = 3, tfont = WINTITLE_FONT, marg = 0, tagstr = "")
{
local loc, oh, nh = 0;
/* check for string */
if (not(isstring(title)))
{
error(sprintf("%s - title string required", __FUNC__));
}
/* 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);
if (isempty(oh))
{
/* legacy */
oh = findtext("winnum", getwnum, "target", target, "margin", marg);
}
}
else
{
/* worksheet text */
oh = findtext("target", target, "font", tfont, "margin", marg, "location", loc, "tag", tagstr);
if (isempty(oh))
{
/* legacy */
oh = findtext("target", target, "margin", marg);
}
}
if (not(isempty(oh)))
{
if (oh.annum < 0)
{
/* legacy */
deletehandle(oh);
oh = {};
}
}
if (isempty(oh))
{
/* add text to target */
nh = text(0.0, 0.0, target, color, -1, tfont, -1, -1, -1, marg, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, loc, caststring(title));
nh.tag = caststring(tagstr);
}
else
{
(fname, height, bold, italic) = getfontspec(tfont);
oh.target = target;
oh.font = tfont;
oh.margin = marg;
oh.location = loc;
oh.tag = caststring(tagstr);
oh.text = caststring(title);
oh.color = color;
oh.fontsize = height;
oh.bold = bold;
oh.italic = italic;
}
}