Creation/Dev/Script/Client/GuiMLTextCtrl

From Graal Bible
Revision as of 14:58, 6 October 2006 by Stefan (talk | contribs) (→‎Tags: Fixed a spelling error)

Inherits GuiControl.

Description

Guicontrol multiline.png

Displays a multi-lined text which can contain several HTML-tags. This should be put in a GuiScrollCtrl to avoid text being clipped and not being displayed.

GuiMLTextCtrl is also used for displaying hints when moving the mouse over a GuiControl.


Variables

allowcolorchars - boolean

allowedtags - string

alpha - float

deniedsound - string

disallowedtags - string

maxchars - integer

parsetags - boolean

syntaxhighlighting - boolean

text - string

wordwrap - boolean


Functions

addtext(str, bool)

getcursorline() - returns integer

getline(int) - returns string

getlinecount() - returns integer

getlines() - returns object - array of lines

gettext() - returns string

reflow()

scrolltobottom()

scrolltotag(int)

scrolltotop()

setlines(obj)

settext(str)


Events

onCursorLineChanged(line) - the cursor has been moved to another line

onSelectedTag(tagid) - an image inside the control has been clicked (<img src=imagefile id=tagid>-tag)

onURL(url) - an url has been clicked (<a href=url>-tag)

onReflow(newwidth,newheight) - the size of the displayed text has been changed


Tags

The text of multi-line text controls can contain a few HTML-tags and Torque-tags, you can use both of those tag types to define colors and fonts or to include images. Currently following tags are available:

HTML:

<a href=url> text </a> - when the user clicks on 'text' then 
  a web browser is opened for the specified url
<b> text </b> - draws text with bold font
<body bgcolor=colorname or #rrggbb> - sets the background color
<br> - line break
<center> text </center> - centers the contained text
<font face=fontname size=textsize color=colorname or #rrggbb> text </font>
  - draws text with a special font, size and color; you only
  need to define one of those 3 attributes
<i> text </i> - draws text with italic font
<ignorelinebreaks> </ignorelinebreaks> - go into normal HTML mode where
  you need to insert <br> to do a linebreak
<img src=filename id=integer> - an image is displayed, you 
  can also specify a tagid if you want to get onSelectTag-events
  for this image
<p align=left/center/right> text </p> - sets the alignment of the 
  contained text
<span style="width=100; height=100;" id=integer> </span> - for 
  displaying a subpage, you can also specifiy an id for 
  onSelectTag-events; instead of <span> you can also use <div> tags

Torque:

<a:url> text </a> - when the user clicks on 'text' then 
  a web browser is opened for the specified url
<bitmap:filename> - an image is displayed
<color:rrggbb> - sets the color of the text (hexadecimal value)
<lmargin:pixels> - sets the left margin for the text
<lmargin%:percent> - sets the size of the left margin depending 
  on the width of the whole control
<linkcolor:rrggbb> - sets the color of links (the <a>-tag)
<linkcolorhl:rrggbb> - sets the highlighted color, when
  the user moves the mouse over a link
<just:left/center/right> - sets the align of the following text
<rmargin:pixels> - sets the right margin for the text
<rmargin%:percent> - sets the size of the right margin depending 
  on the width of the whole control
<sbreak> - line break
<spush> - switches to a new style (like <font>)
<spop> - switches back to the last saved style (like </font>)
<tab:tab1,tab2,..> - sets the position of where tabulators should
  be displayed if you have text like 'Apple \t Egg \t Chicken'
<tag:id> - inserts an invisible tag which can be used
  for the scrollToTag(id) function (beside image-tags)

Example

new GuiMLTextCtrl("Test_MultiLineText") {
  profile = GuiBlueMLTextProfile;
  x = 10;
  y = 10;
  width = 160;
  height = 60;
  text = "<font size=24><i>Multiline-<br>Text</i></font>";
}