@-commands


Functions

void fltk::add_symbol (const char *name, void(*drawit)(Color), int scalable)

Detailed Description

When calling drawtext() (or assigning labels or tooltips or any other strings that call drawtext()) you can imbed @-commands into the text. These actually look up instances of Symbol which then can modify the drawing.

symbols.gif

"&x" underscores the 'x'. This is a standard from Microsoft.

"&&" prints a single "&".

"@@" prints a single "@" sign. This is not a symbol, the next character is printed or interpreted even if it is a semicolon or space.

"@;" truncates the string at this point. This can be used to hide program internal data in the label() by putting this before it.

"@n" in a label resets the font, color, and postioning offset to the settings they were when the label started.

"@b" in a label changes the font to bold.

"@i" in a label changes the font to italic.

"@f" or "@t" in a label changes the font to fixed fltk::COURIER

"@Cxyz" will change the color to xyz, which is a color number. It is easiest to specify it in hex, such as 0xff000000 for red.

"@snumber" will set the font size directly to the number.

"@s+number" will set it to (12+n)/12 times the current size.

"@s-number" will set it to 12/(12+n) times the current size.

"@s0" will restore the initial size.

Capital S works as well for back-compatability.

"@." prints nothing and also stops any interpretation of @ or & characters later in the string. This will allow you to concatenate some @-commands to the start of an arbitrary string.

"@mxnumber" draws a blank exactly n pixels wide. N may be negative. This is useful for kerning or overprinting characters. For positive N please use a '+' sign, so that unsigned values can be reserved for future use.

"@xnumber" draws a blank exactly n*(fontsize/12) wide. N may be negative. This is useful for kerning or overprinting characters. For positive N please use a '+' sign, so that unsigned values can be reserved for future use.

"@ynumber" will move the y origin up (not down) by n*(fontsize/12) pixels. The "@n" command will restore the y origin to the baseline.

This can be used to produce super/subscripts. You should start positive numbers with '+' for compatability with possible future versions of fltk.

"@Bcolor" draws a solid box of the given color behind the text. Not sure if this is compatable with fltk1.1.

"@l" makes the rest of the label be left-justified. Note that this is incompatable with fltk1, which used this to set the size to 24 points.

"@c" makes the rest of the label be centered.

"@r" makes the rest of the label be right-justified.


Function Documentation

void add_symbol const char *  name,
void(*)(Color drawit,
int  scalable
 

Define a (hidden) subclass of Symbol that will draw a square icon. All the predefined displaying symbols in fltk use this.

This is called by "@name;" in a label. By default the square is the current font size. The name may be prefixed with some extra characters:

"+digit" will enlarge the square by 1/12 of a point size, "-digit" will shrink it. For instance "@+2square;" will make a larger than default square.

Any digits after that are taken as an angle to rotate. A single digit is a "keypad rotation" where the x axis points at the given number on a keypad, for instance '9' it 45 degrees up, and '4' is upside-down. '5' and '6' cause no rotation. For instance "@4>" will make a triangle pointing left. "@+14>" is a bigger triangle pointing left.

Multiple digits are a rotation in degrees. To do a rotation less than 10 degrees use a leading zero. For instance "@25->" is an arrow pointing 25 degrees up. "@-125->" is a slightly smaller arrow pointing 25 degrees up.

The drawit function should draw the required image inside the -1,-1 to 1,1 square. The current transformation will already be set to place this in the right place. The current color is passed as an argument, you do not have to use this, but if you change the color you are expected to set it back.

The scalable argument is for back-compatability and is ignored. Pass 1 for compatability. If you want to make a non-scalable symbol you should define your own subclass of Symbol.


Sun May 8 21:48:57 2005. FLTK ©2004 Bill Spitzak and others. See Main Page for details.