Drawing text¶
DrawText() |
Draw text |
SYNTAX
DrawText(window_id, xpos, ypos, text, font, width, height)
Draw a piece of text at a specified location.
window_id |
The identifier of the window in which the text is to be placed. To print it in the current report, specify NULL instead of a window_id. |
xpos, ypos |
The x and y co-ordinates of the position where the upper-left corner of the text is to appear. |
text |
The text to be drawn. It can be a field, an expression or a quoted string. |
font |
The font parameter requires the same syntax as a window or control font clause. Unless a valid font specification is provided, the default specified in Section 1.4 (Default font) of the terminal parameter file is used. The standard terminal parameter file for all versions of Windows is $SCULPTOR/term/mswin.s. See Terminal parameter files. If no default font is defined, then Courier New@10 (Courier New, 10 point) is used as the default. |
width
height
|
These parameters can be set to NULL, or they can be fields. If they are fields, the function fills them with the actual width and height (in device units) of the rectangle containing the text. |
Formatting¶
Formatting of text drawn by the DrawText() function is controlled by text alignment flags, defined in $SCULPTOR/include/draw.h with the prefix TA_. The SetTextAlign() function sets the flags and the GetTextAlign() function retrieves the current flags set.
The flags that can be set are as follows:
TA_LEFT |
Informs DrawText() that xpos is the co-ordinate for the left end of the text. Text printed with the same xpos co-ordinate is left-aligned. TA_LEFT is defined as 0. If it is combined with a conflicting flag such as TA_RIGHT, the non-zero value takes precedence. |
TA_RIGHT |
Informs DrawText() that xpos is the co-ordinate for the right end of the text. Text printed with the same xpos co-ordinate is right-aligned. |
TA_CENTRE | TA_CENTER |
Informs DrawText() that xpos is the co-ordinate for the centre of the text. Text printed with the same xpos co-ordinate is centre-aligned. |
TA_TOP |
Informs DrawText() that ypos is the co-ordinate for the top of the text. Text printed with the same ypos co-ordinate is aligned along the top, regardless of its font height. This is the default for text drawn in a window. TA_TOP is defined as 0. If it is combined with a conflicting flag such as TA_BOTTOM, the non-zero value takes precedence. |
TA_BOTTOM |
Informs DrawText() that ypos is the co-ordinate for the bottom of the text. Text printed with the same ypos co-ordinate is aligned along the bottom, regardless of its font height. This is the default for text drawn in a report and is compatible with the Sculptor print command. |
TA_BASELINE |
Align text to the baseline. This is not the same as TA_BOTTOM. TA_BOTTOM is the very bottom of the text, below descenders on characters such as “p” and “q”. TA_BASELINE is the line below which the descenders hang. |
TA_RTLREADING |
Use right to left order if the font is Hebrew or Arabic. |
TA_REPORTDEFAULT |
Default formatting for text drawn in reports. To retain compatibility with other Sculptor code, programs should reset text alignment flags for text drawn in a report to TA_REPORTDEFAULT. |
TA_SCREENDEFAULT |
Default formatting for text drawn in windows. To retain compatibility with other Sculptor code, programs should reset text alignment flags for text drawn in a window to TA_SCREENDEFAULT. |
NOTES
The getprintxy() and setprintxy() functions are available to help with positioning when draw functions are mixed with Sculptor print[h] commands.
The DrawFormattedText() function is similar to DrawText() but offers more powerful formatting options.
- EXAMPLE
DrawText(wintask, 20, 10, tmp.TextField, "helvetica,b@12", 300, 200)
RELATED TOPICS |