This function draws the text str at position (x, y) on the specified drawable. The text will be drawn in the foreground color of the graphics context gc. If the usebackground flag of the GC is set, then the text background will be drawn in the GC's background color. If the usebackground flag is clear, then the text background will not be drawn.
Type | Name | Description |
---|---|---|
GR_DRAW_ID | id | The ID of the drawable to draw the text onto. |
GR_GC_ID | gc | The ID of the graphics context to use when drawing the text. |
GR_COORD | x | The X coordinate to draw the text at, relative to the drawable. |
GR_COORD | y | The Y coordinate to draw the text at, relative to the drawable. |
void* | str | The input string. If the string is NOT zero terminated, then the length of the string must be specified in the count parameter. |
GR_COUNT | count | The length of the string. This parameter can be set to -1 if the string is zero terminated and flags contains GR_TFASCII. |
int | fags | Text rendering flags, can be a combination of flags listed below. |
The flags parameter is a combination of flags from the following three groups. The combination can include one string encoding flag, one alignment flag and multiple attribute flags.
String encoding flags:
Text alignment flags:
Text attribute flags:
Example 2-1. Using GrText()
#include <stdio.h> #define MWINCLUDECOLORS #include "microwin/nano-X.h" GR_WINDOW_ID wid; GR_GC_ID gc; void event_handler (GR_EVENT *event); int main (void) { if (GrOpen() < 0) { fprintf (stderr, "GrOpen failed"); exit (1); } gc = GrNewGC(); GrSetGCUseBackground (gc, GR_FALSE); GrSetGCForeground (gc, RED); wid = GrNewWindowEx (GR_WM_PROPS_APPFRAME | GR_WM_PROPS_CAPTION | GR_WM_PROPS_CLOSEBOX, "Hello Window", GR_ROOT_WINDOW_ID, 50, 50, 200, 100, WHITE); GrSelectEvents (wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ); GrMapWindow (wid); GrMainLoop (event_handler); } void event_handler (GR_EVENT *event) { switch (event->type) { case GR_EVENT_TYPE_EXPOSURE: GrText (wid, gc, 50, 50, "Hello World", -1, GR_TFASCII); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); exit (0); } } |