Roxen.git / server / modules / graphics / graphic_text.pike

version» Context lines:

Roxen.git/server/modules/graphics/graphic_text.pike:1:   // This is a roxen module. Copyright © 1996 - 2000, Roxen IS.   //    - constant cvs_version="$Id: graphic_text.pike,v 1.211 2000/03/15 20:35:08 wellhard Exp $"; + constant cvs_version="$Id: graphic_text.pike,v 1.212 2000/03/16 00:32:53 nilsson Exp $";      #include <module.h>   inherit "module";   inherit "roxenlib";         // ------------------- Module registration ---------------------      constant module_type = MODULE_PARSER;   constant module_name = "Graphics text";
Roxen.git/server/modules/graphics/graphic_text.pike:30:    defvar("ext", 0, "Append .fmt (gif, jpeg etc) to all images",    TYPE_FLAG|VAR_MORE,    "Append .gif, .png, .gif etc to all images made by gtext. "    "Normally this will only waste bandwidth");   }      TAGDOCUMENTATION;   #ifdef manual   constant gtextargs=#"   <attr name=afont> -  <ex> -  <gtext afont>foo</gtext> -  </ex> +    </attr>      <attr name=alpha value=path>    Use the specified image as an alpha channel, together with the    background attribute. -  <ex> -  <gtext +    </attr>      <attr name=background value=path>    Specifies the image to use as background.   </attr>      <attr name=bevel value=width>    Draws a bevel box.   </attr>      <attr name=bgcolor value=color>    Sets the background color. Normally taken from the normal HTML tags    in your document (Currently: body, table, tr or td).       <p>If you set the background color, it is probably best to add the    notrans attribute as well.</p>    <ex type=vert> -  <gtext notrans bgcolor=pink>Pink</gtext> -  <gtext notrans bgcolor=red>Red</gtext> -  <gtext notrans bgcolor=%50,0,100,0>%50,0,100,0</gtext> + <gtext notrans=\"\" bgcolor=\"pink\">Pink</gtext> + <gtext notrans=\"\" bgcolor=\"#ff0000\">Red</gtext> + <gtext notrans=\"\" bgcolor=\"%50,0,100,0\">%50,0,100,0</gtext>    </ex>   </attr>    - <attr name=bgturbulence value=frequency,color;frequency,color;frequency,color> + <attr name=bgturbulence value=frequency,color;frequency,color...>    Apply a turbulence effect.   </attr>      <attr name=black>    Use a black, or heavy, version of the font, if available.   </attr>      <attr name=bold>    Use a bold version of the font, if available.   </attr>      <attr name=bshadow value=distance>    Draw a blured black drop-shadow behind the text. Using 0 as distance    does not currently place the shadow directly below the text. Using    negative values for distance is possible, but you might have to add    'spacing'.    <ex type=vert> -  <gtext scale=0.8 fgcolor=darkblue quant=200 bshadow=1>&lt;gtext quant=100 bshadow=1&gt;</gtext><br> -  <gtext scale=0.8 fgcolor=darkblue quant=200 bshadow=2>&lt;gtext quant=100 bshadow=2&gt;</gtext> + <gtext scale=\"0.8\" fgcolor=\"#FF6600\" quant=\"200\" bshadow=\"1\">&lt;gtext bshadow=1&gt;</gtext><br /> + <gtext scale=\"0.8\" fgcolor=\"#FF6600\" quant=\"200\" bshadow=\"2\">&lt;gtext bshadow=2&gt;</gtext>    </ex>   </attr>      <attr name=chisel>    Make the text look like it has been cut into the background.    <ex type=vert> -  <gtext bold quant=200 ypad=-40% xpad=-20% chisel talign=center -  opaque=70 fgcolor=gold bevel=2 background=tiles.jpg> Chisel + <gtext bold=\"\" quant=\"200\" ypad=\"-40%\" xpad=\"-20%\" chisel=\"\" talign=\"center\" + opaque=\"70\" fgcolor=\"gold\" bevel=\"2\" background=\"tiles.jpg\"> Chisel   opaque=70</gtext>    </ex>   </attr>      <attr name=crop>    Remove all white-space around the image   </attr>      <attr name=encoding>      </attr>      <attr name=fadein value=blur,steps,delay,initialdelay>    Generates an animated GIF file of a fade-in effect.   </attr>      <attr name=fgcolor value=color>    Sets the text color.       <ex type=vert> -  <gtext fgcolor=#0080FF>#0080FF</gtext> + <gtext fgcolor=\"#0080FF\">#0080FF</gtext>    </ex>   </attr>      <attr name=font>      </attr>      <attr name=font_size>      </attr>
Roxen.git/server/modules/graphics/graphic_text.pike:134: Inside #if defined(manual)
     </attr>      <attr name=fs>    Apply floyd-steinberg dithering to the resulting image. Most of the    time it is much better to increase the number of colors, instead of    dithering the image, but sometimes when using very complex background    images dithering is O.K.   </attr>    - <attr name=fuzz value=color> -  Apply a glow effect. -  <ex type=vert> -  <gtext fuzz=pink>fuzz=pink</gtext> -  </ex> - </attr> -  +    <attr name=ghost value=dist,blur,color>    Apply a ghost effect. Cannot be used together with shadow or magic    coloring.    <ex type=vert> -  <gtext spacing=2 crop quant=200 ghost=1,1,red>ghost=1,1,red</gtext> -  <gtext spacing=2 crop quant=200 ghost=1,3,blue>ghost=1,3,blue</gtext> -  <gtext spacing=2 crop bshadow=1 opaque=90 ghost=-1,1,yellow>ghost=-1,1,yellow opaque=90 bshadow=1</gtext> + <gtext spacing=\"2\" crop=\"\" quant=\"200\" ghost=\"1,1,red\">ghost=1,1,red</gtext> + <gtext spacing=\"2\" crop=\"\" quant=\"200\" ghost=\"1,3,blue\">ghost=1,3,blue</gtext> + <gtext spacing=\"2\" crop=\"\" bshadow=\"1\" opaque=\"90\" ghost=\"-1,1,yellow\">ghost=-1,1,yellow opaque=90 bshadow=1</gtext>    </ex>   </attr>      <attr name=glow value=color>    Apply a 'glow' filter to the image. Quite a CPU eater. Looks much    better on a dark background, where a real 'glow' effect can be    achieved.    <ex type=vert> -  <gtext quant=200 glow=red>&lt;gtext glow=red&gt;</gtext> + <gtext quant=\"200\" glow=\"red\">&lt;gtext glow=red&gt;</gtext>    </ex>   </attr>      <attr name=italic>    Use an italic version of the font, if available.   </attr>      <attr name=light>    Use a light version of the font, if available.   </attr>
Roxen.git/server/modules/graphics/graphic_text.pike:196: Inside #if defined(manual)
     <attr name=nfont value=fontname>    Select a font using somewhat more memonic font-names. You can get a    font-list by accessing the configuration interface.       <p>There are several modifiers available: bold, italic, black and light.    If the requested version of the font is available, it will be used to    render the text, otherwise the closest match will be used.</p>       <ex type=vert> -  <gtext nfont=futura light >Light</gtext> -  <gtext nfont=futura light italic>Italic</gtext> -  <gtext nfont=futura >Normal</gtext> -  <gtext nfont=futura italic >Italic</gtext> -  <gtext nfont=futura bold >Bold</gtext> -  <gtext nfont=futura bold italic >Italic</gtext> -  <gtext nfont=futura black >Black</gtext> -  <gtext nfont=futura black italic>Italic</gtext> + <gtext nfont=\"futura\" light=\"\" >Light</gtext> + <gtext nfont=\"futura\" light=\"\" italic=\"\">Italic</gtext> + <gtext nfont=\"futura\" >Normal</gtext> + <gtext nfont=\"futura\" italic=\"\" >Italic</gtext> + <gtext nfont=\"futura\" bold=\"\" >Bold</gtext> + <gtext nfont=\"futura\" bold=\"\" italic=\"\">Italic</gtext> + <gtext nfont=\"futura\" black=\"\" >Black</gtext> + <gtext nfont=\"futura\" black=\"\" italic=\"\">Italic</gtext>    </ex>   </attr>      <attr name=notrans>    Do not make the background transparent. Useful when making 'boxes' of    color around the text.    <ex type=vert> -  <gtext bgcolor=red>&lt;gtext bgcolor=red&gt;</gtext> -  <gtext bgcolor=red notrans>&lt;gtext bgcolor=red notrans&gt;</gtext> + <gtext bgcolor=\"red\">&lt;gtext bgcolor=red&gt;</gtext> + <gtext bgcolor=\"red\" notrans=\"\">&lt;gtext bgcolor=red notrans&gt;</gtext>    </ex>   </attr>      <attr name=nowhitespace>      </attr>      <attr name=opaque value=percentage>    Generate text with this amount of opaqueness. 100% is default.    <ex> -  <gtext fgcolor=blue opaque=50>Opaque</gtext> + <gtext fgcolor=\"blue\" opaque=\"50\">Opaque</gtext>    </ex>   </attr>      <attr name=outline>      </attr>      <attr name=pressed>    Inverts the direction of the bevel box, to make it look like a button    that is pressed down.
Roxen.git/server/modules/graphics/graphic_text.pike:253: Inside #if defined(manual)
   Rescale the background to fill the whole image.   </attr>      <attr name=rotate value=angle>    Rotates the image this number of degrees counter-clockwise.   </attr>      <attr name=scale value=number>    Sets the scale of the image. Larger than 1.0 is enlargement.    <ex type=vert> -  <gtext scale=1.0>&lt;gtext scale=1.0&gt;</gtext> -  <gtext scale=0.5>&lt;gtext scale=0.5&gt;</gtext> + <gtext scale=\"1.0\">&lt;gtext scale=1.0&gt;</gtext> + <gtext scale=\"0.5\">&lt;gtext scale=0.5&gt;</gtext>    </ex>   </attr>      <attr name=scolor value=color>    Use this color for the shadow. Used with the shadow attribute.   </attr>      <attr name=scroll value=width,steps,delay>    Generate an animated GIF image of the text scrolling.   </attr>
Roxen.git/server/modules/graphics/graphic_text.pike:358: Inside #if defined(manual)
   <tag>body</tag>> tag of the page, the bg and fg attributes must be    set, otherwise the <tag>gtext</tag>> tag will only render a \"Please    reload this page\" message.</p>   </desc>      <attr name=alt value=string>    Sets the alt attribute of the generated <tag>img</tag> tag. By    default the alt attribute will be set to the contents of the    <tag>gtext</tag> tag.    <ex type=vert> -  <gtext fgcolor=blue alt=\"Hello!\">Point your mouse here</gtext> + <gtext fgcolor=\"blue\" alt=\"Hello!\">Welcome!</gtext>    </ex>   </attr>      <attr name=border value=width,color>    Draws a border around the text of the specified width and color.    <ex type=vert> -  <gtext fgcolor=blue border=1,pink>Pink border</gtext> + <gtext fgcolor=\"blue\" border=\"2,red\">Red border</gtext>    </ex>   </attr>      <attr name=href value=URL>    Link the image to the specified URL. The link color of the document    will be used as the default foreground rather than the foreground    color.   </attr>      <attr name=magic value=message>    Used together with the href attribute to generate a JavaScript that    will highlight the image when the mouse is moved over it. The message    is shown in the browser's status bar.    <ex type=vert> -  <gtext href=http://www.roxen.com magic=HERE!>www.roxen.com</gtext> + <gtext href=\"http://www.roxen.com\" magic=\"Roxen\">www.roxen.com</gtext>    </ex>   </attr>    - <attr name=magic_attribute value=value> Same as for any + <attr name=magic-attribute value=value> Same as for any    <tag>gtext</tag> attribute, except for the highlighted image.    <ex type=vert> -  <gtext fgcolor=blue>Magic_attribute</gtext> + <gtext fgcolor=\"blue\" magic-fgcolor=\"darkgreen\" magic=\"\">Magic_attribute</gtext>    </ex>   </attr>    - <attr name=magicbg value=color,path> -  Same as the background attribute, except for the highlighted image. - </attr> -  +    <attr name=noxml>      </attr>      <attr name=split>    <gtext scale=0.4 split>Make each word into a separate gif image.    Useful if you are writing a large text, and word wrap at the edges of    the display is desired. This text is an example (try resisizing your    browser window, the images should move just like normal text    would)</gtext>       <p>This will allow the browser to word-wrap the text, but will disable certain attributes like magic.</p>       <ex type=vert> -  <gtext scale=0.4 split>Make each word..</gtext> + <gtext scale=\"0.4\" split=\"\">Make each word..</gtext>    </ex>   </attr>      <attr name=submit>    Creates a submit-button for forms. Does not work together with split    or magic arguments. - </attr>", + </attr>"+gtextargs,      "gtext-id":#"<desc tag></desc>   <attr name=href value=URL>    Link the image to the specified URL. The link color of the document    will be used as the default foreground rather than the foreground    color.   </attr>      <attr name=short>    - </attr>", + </attr>"+gtextargs,      "gtext-url":#"<desc cont></desc>      <attr name=href value=URL>    Link the image to the specified URL. The link color of the document    will be used as the default foreground rather than the foreground    color.   </attr>      <attr name=short>    - </attr>",]); + </attr>"+gtextargs,]);   #endif         // -------------------- Image cache functions --------------------      roxen.ImageCache image_cache;      string status() {    array s=image_cache->status();    return sprintf("<b>Images in cache:</b> %d images<br>\n<b>Cache size:</b> %s",
Roxen.git/server/modules/graphics/graphic_text.pike:731:   }      string fix_text(string c, mapping m, RequestID id) {       if(m->nowhitespace)    {    c=String.trim_all_whites(c);    m_delete(m, "nowhitespace");    }    -  if(!m->noparse && !m->preparse) -  c = parse_rxml(c, id); -  else { +     m_delete(m, "noparse");    m_delete(m, "preparse"); -  } +        c=replace(c, replace_entities+({" "," ", "\n\n\n", "\n\n", "\r"}),    replace_values+({" ", " ", "\n", "\n", ""}));       if(m->maxlen) {    c = c[..(((int)m->maxlen||QUERY(deflen))-1)];    m_delete(m, "maxlen");    }       return c;   }         // ----------------- gtext tags and containers -------------------    - string container_gtext_url(string t, mapping arg, string c, RequestID id) { + string simpletag_gtext_url(string t, mapping arg, string c, RequestID id) {    c=fix_text(c,arg,id);    mapping p=mk_gtext_arg(arg,id);    if(arg->href && !p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";    string ext="";    if(query("ext")) ext="."+(p->format || "gif");    if(!arg->short)    return query_internal_location()+image_cache->store( ({p,c}), id )+ext;    return "+"+image_cache->store( ({p,c}), id )+ext;   }    - string tag_gtext_id(string t, mapping arg, RequestID id) { + string simpletag_gtext_id(string t, mapping arg, string c, RequestID id) {    mapping p=mk_gtext_arg(arg,id);    if(arg->href && !p->fgcolor) p->fgcolor=id->misc->gtext_link||"#0000ff";    if(!arg->short)    return query_internal_location()+"$"+image_cache->store(p, id)+"/";    return "+"+image_cache->store(p, id )+"/foo";   }    - string container_gtext(string t, mapping arg, string c, RequestID id) + string simpletag_gtext(string t, mapping arg, string c, RequestID id)   {    if((c-" ")=="") return "";       c=fix_text(c,arg,id);    mapping p=mk_gtext_arg(arg,id);       string ext="";    if(query("ext")) ext="."+(p->format || "gif");       string lp="%s", url="", ea="";
Roxen.git/server/modules/graphics/graphic_text.pike:841:    arg->height=(string)size->ysize;    }       if(arg->magic)    {    string magic=replace(arg->magic,"'","`");    m_delete(arg,"magic");       if(p->bevel) p->pressed=1;    +  m_delete(p, "fgcolor");    foreach(glob("magic-*", indices(arg)), string q)    {    p[q[6..]]=arg[q];    m_delete(arg, q);    }    -  if(!arg->fgcolor) p->fgcolor=id->misc->defines->theme_alink|| +  if(!p->fgcolor) p->fgcolor=id->misc->defines->theme_alink||    id->misc->defines->alink||"#ff0000";       string num2 = image_cache->store( ({ p, c }),id );    size = image_cache->metadata( num2, id );    if(size) {    arg->width=(string)max(arg->xsize,size->xsize);    arg->height=(string)max(arg->ysize,size->ysize);    }       if(!id->supports->images) return sprintf(lp,arg->alt);
Roxen.git/server/modules/graphics/graphic_text.pike:895:    "onMouseout=\"top.window.status='';document.images['"+sn+"'].src = "+sn+"l.src;\">"    +make_tag("img",arg)+"</a>";    }       if(input)    return make_tag("input",arg+(["type":"image"]));       return sprintf(lp,make_tag("img",arg));   }    - array(string) container_gh(string t, mapping m, string c, RequestID id) { + array(string) simpletag_gh(string t, mapping m, string c, RequestID id) {    int i;    if(sscanf(t, "%s%d", t, i)==2 && i>1)    m->scale = (string)(1.0 / ((float)i*0.6));    if(!m->valign) m->valign="top"; -  return ({ "<p>"+container_gtext("",m,c,id)+"<br>" }); +  return ({ "<p>"+simpletag_gtext("",m,c,id)+"<br>" });   }    - array(string) container_anfang(string t, mapping m, string c, RequestID id) { + array(string) simpletag_anfang(string t, mapping m, string c, RequestID id) {    if(!m->align) m->align="left"; -  return ({ "<br clear=\"left\">"+container_gtext("",m,c[0..0],id)+c[1..] }); +  return ({ "<br clear=\"left\">"+simpletag_gtext("",m,c[0..0],id)+c[1..] });   }         // --------------- tag and container registration ----------------------    - mapping query_tag_callers() - { -  return ([ "gtext-id":tag_gtext_id ]); + mapping query_simpletag_callers() { +  return ([ "gtext-id" : ({ RXML.FLAG_EMPTY_ELEMENT, simpletag_gtext_id }), +  "gtext-url" : ({ 0, simpletag_gtext_url }), +  "anfang" : ({ 0, simpletag_anfang }), +  "gh1" : ({ 0, simpletag_gh }), +  "gh2" : ({ 0, simpletag_gh }), +  "gh3" : ({ 0, simpletag_gh }), +  "gh4" : ({ 0, simpletag_gh }), +  "gh5" : ({ 0, simpletag_gh }), +  "gh6" : ({ 0, simpletag_gh }), +  "gtext" : ({ 0, simpletag_gtext }), +  ]);   } -  - mapping query_container_callers() - { -  return ([ "anfang":container_anfang, -  "gtext-url":container_gtext_url, "gh":container_gh, -  "gh1":container_gh, "gh2":container_gh, -  "gh3":container_gh, "gh4":container_gh, -  "gh5":container_gh, "gh6":container_gh, -  "gtext":container_gtext ]); - } +