Note: The Agar manual pages follow certain conventions, notably concerning function return values. Please read AG_Intro(3) first.
SYNOPSIS
#include <agar/core.h> #include <agar/gui.h> |
DESCRIPTION
| The AG_Textbox widget allows the user to edit UTF-8 encoded text. It provides the basic AG_Editable(3) interface and adds a built-in text label, cosmetics and scrollbars in multiline mode. |
INHERITANCE HIERARCHY
| AG_Object(3)-> AG_Widget(3)-> AG_Textbox. |
INITIALIZATION
|
The AG_TextboxNew() function allocates, initializes, and attaches a new AG_Textbox widget. The optional string argument specifies a text label to display at the left of the textbox. Acceptable flags include:
The AG_TextboxBindUTF8() and AG_TextboxBindASCII() functions bind the textbox to a text buffer in UTF-8 or plain ASCII encoding, respectively. The bufferSize argument indicates the complete size of the buffer in bytes. The AG_TextboxSetStatic() function enables or disables static optimizations at runtime (see AG_TEXTBOX_STATIC flag description). The AG_TextboxSetPassword() function enables/disables password-type input, where characters are substituted for " * " in the display. AG_TextboxSetWordWrap() enables/disable word wrapping. AG_TextboxSetIntOnly() restricts input to integers (see flags) AG_TextboxSetFltOnly() restricts input to real numbers (see flags). AG_TextboxSetFont() configures an alternate font (see AG_FetchFont(3)). It is also legal to modify the font pointer of the AG_Textbox object (see STRUCTURE DATA). AG_TextboxSetLabel() changes the current label text to the specified string. AG_TextboxSizeHint() requests that the initial geometry of textbox is to be sufficient to display the string text in its entirety. The AG_TextboxSizeHintPixels() variant accepts arguments in pixels. AG_TextboxSizeHintLines() accepts a number of lines. |
CURSOR MANIPULATION
TEXT MANIPULATION
The AG_TextboxPrintf() function uses vsnprintf(3) to overwrite the contents of the buffer. If the fmt argument is NULL, a NUL string is assigned instead. AG_TextboxSetString() overwrites the contents of the buffer with the given string. The argument may be NULL to clear the string. AG_TextboxSetStringUCS4() accepts a string in UCS-4 encoding. AG_TextboxClearString() clears the contents of the buffer. The AG_TextboxDupString() function returns a copy of the text buffer. The AG_TextboxCopyString() function copies up to dst_size - 1 bytes from the text buffer dst, NUL-terminating the result and returning the number of bytes that would have been copied if dst_size was unlimited. The AG_TextboxBufferChanged() function signals an outside change in the buffer contents. It is only useful if the Nm AG_TEXTBOX_STATICflag is set. AG_TextboxInt(), AG_TextboxFlt() and AG_TextboxDbl() perform conversion of the string contents to int float and double, respectively and return the value. You probably want to be using the AG_Numerical(3) widget instead of these functions. |
BINDINGS
The
AG_Textbox widget provides the following bindings:
|
EVENTS
The
AG_Textbox widget reacts to the following events:
The AG_Textbox widget generates the following events:
|
STRUCTURE DATA
For the
AG_Textbox object:
|
EXAMPLES
The following code fragment binds an
AG_Textbox to a string contained in a fixed-size buffer:
char name[32]; AG_Textbox *tb; tb = AG_TextboxNew(parent, 0, "Name: "); AG_TextboxBindUTF8(tb, name, sizeof(name)); As is the case with all widgets, a "default" binding (limited to AG_TEXTBOX_STRING_MAX bytes) is provided. The following code uses and AG_TextboxDupString() on the default binding: AG_Textbox *tb; char *value_ptr; tb = AG_TextboxNew(parent, 0, "Value: "); AG_TextboxPrintf(tb, "Foo"); value_ptr = AG_TextboxDupString(tb); Also see demos/textbox in the Agar source distribution. |
SEE ALSO
| AG_Intro(3), AG_Text(3), AG_Tlist(3), AG_Widget(3), AG_Window(3) |
HISTORY
| The AG_Textbox widget first appeared in Agar 1.0. It was mostly rewritten as AG_Editable(3) was added in Agar 1.3.2. Support for dynamically-resized text buffers was added in Agar 1.4.0. |
