String Display Functions

The fg_print() function displays a character string relative to the current graphics position. It performs automatic clipping so strings do not extend beyond the edges of the virtual buffer or client area. By default, fg_print() displays strings in the client area. Strings displayed with fg_print() have transparent backgrounds, so if you display one string on top of another, parts of the first string may still be visible beneath the second string. To avoid this, first erase the area where the string will appear. The easiest way to do this is by calling fg_rect() to draw a rectangle in the background color.

The fg_print() function displays a character string in the current color, relative to the current graphics position. By default, strings are written directly to the client area, with the lower left corner of the first character at the graphics cursor position. The fg_print() function leaves the graphics cursor just to the right of the last character displayed, making it possible for successive fg_print() calls to display adjacent strings. The first parameter for fg_print() is a character string of arbitrary length, and the second parameter is an integer value that specifies the number of characters to display from that string. For example,

C/C++:

fg_setcolor(20);
fg_print("Hello",5);

Delphi:

fg_setcolor(20);
fg_print('Hello',5);

Visual Basic:

Call fg_setcolor(20)
Call fg_print("Hello", 5)

displays the string "Hello" in color 20, with the lower left corner of the "H" at the graphics cursor position.

The fg_justify() function defines the fg_print() justification. Its two parameters, xjust and yjust, control the string positioning relative to the current graphics position, as summarized in the following table:

value of xjust

value of yjust

horizontal justification

vertical justification

-1

-1

left

lower

-1

0

left

center

-1

1

left

upper

0

-1

center

lower

0

0

center

center

0

1

center

upper

1

-1

right

lower

1

0

right

center

1

1

right

upper

Any other justification values produce undefined results. In the context of vertical justification, lower justification means the bottom of each character will be at the current graphics y position. Upper justification means the top of each character will be at the graphics y position, while center justification means characters will be centered about the graphics y position. The default justification settings established by fg_vbinit() are xjust = -1 and yjust = -1, and you can retrieve the current justification settings with the fg_getxjust()fg_getxjust and fg_getyjust() functions.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.