|
NAMEAG_Label —
agar label widget
SYNOPSIS#include <agar/core.h> #include <agar/gui.h> DESCRIPTIONTheAG_Label widget displays single-line or multi-line
text. In the case of ‘polled’ labels, the text can contain
elements which are going to be dereferenced on rendering.
INHERITANCE HIERARCHYAG_Object(3) -> AG_Widget(3) ->AG_Label .
INITIALIZATIONAG_Label *AG_LabelNew (AG_Widget
*parent, Uint flags,
const char *fmt,
...);
The The See LABEL FLAGS section for
a the accepted flags values for
The The
The enum ag_text_justify { AG_TEXT_LEFT, AG_TEXT_CENTER, AG_TEXT_RIGHT };
enum ag_text_valign { AG_TEXT_TOP, AG_TEXT_MIDDLE, AG_TEXT_BOTTOM }; The POLLED LABELSAG_LabelNewPolled () and
AG_LabelNewPolledMT () may be used to display a label
containing dynamically accessed elements (i.e., the actual string will be
compiled on rendering). AG_LabelNewPolled () accepts an
Agar-style format string (see
AG_String(3)
for details). Subsequent arguments must be pointers (as opposed to literal
data), and the formatting engine also provides Agar-specific extensions.
Note that the length of polled labels is difficult to determine
automatically, so EVENTSTheAG_Label widget does not generate any event.
LABEL FLAGSThe followingAG_Label flags are
defined:
EXAMPLESThe following code snippet creates a window containing both a static label and a polled label:AG_Window *win; int myInt = 1234; AG_Label *myLbl; win = AG_WindowNew(0); AG_LabelNew(win, 0, "Foo"); myLbl = AG_LabelNewPolled(win, 0, "myInt=%i", &myInt); AG_LabelSizeHint(myLbl, 1, "myInt=0000"); Thread-safe code can associate polled labels with mutexes protecting the data to access: int myInt = 1234; AG_Mutex myMutex = AG_MUTEX_INITIALIZER; AG_LabelNewPolledMT(win, 0, &myMutex, "myInt=%i", &myInt); The following code fragment defines a custom format specifier,
which can be used in polled labels (and is also recognized by
size_t
PrintMyVector(AG_FmtString *fs, char *dst, size_t dstSize)
{
struct my_vector *my = AG_LABEL_ARG(fs);
return AG_Snprintf(dst, dstSize, "[%f,%f]", my->x, my->y);
}
SEE ALSOAG_FetchFont(3), AG_Intro(3), AG_Pixmap(3), AG_String(3), AG_Widget(3), AG_Window(3)HISTORYTheAG_Label widget first appeared in Agar 1.0. In Agar
1.5.0, the formatting engine for "polled labels" was rewritten and
generalized.
Visit the GSP FreeBSD Man Page Interface. |