LWXGL provides seven built-in widget types identified by integer IDs. Each widget is created by aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DREssedAlarm184/LWXGL/llms.txt
Use this file to discover all available pages before exploring further.
GCreate* function and rendered automatically each frame. Elements are stored in a global flat array indexed by the integer ID you supply — creating a new element at an already-occupied ID silently frees the old one first.
Text
(x, y). color is a palette index in the range 0–15. text supports newlines (\n); each line is drawn 15 pixels below the previous one.
Button
u, hvr, and p parameters are packed-nibble color values — the high nibble sets the border color and the low nibble sets the fill color — for the unpressed, hover, and pressed states respectively. onclick is invoked on left-button release while the cursor is inside the button.
0x70 means palette color 7 (light gray) border and palette color 0 (black) fill in the normal state; 0x07 inverts them for the pressed state.
Input
max is the maximum number of characters the user can type; the internal buffer is always 128 bytes. Pass w = -1 to have LWXGL automatically size the box to fit max characters.
GGetInput returns a pointer to the internal character buffer — read it directly.
Checkbox
size controls the side length of the box in pixels. cb_col is a packed nibble (high = border color, low = fill color). txt_col is a plain palette index for the label text.
GGetCheckbox returns 1 if the checkbox is currently checked, 0 otherwise.
Rect
fg is the border color and bg is the fill color (both plain palette indices). Pass -1 for fg to omit the border, or -1 for bg to draw a border-only (hollow) rectangle.
Console
cols and rows are the console’s dimensions in characters — each character cell is 9 pixels wide and 15 pixels tall, so the resulting widget is (cols * 9 + 17) × (rows * 15 + 10) pixels in size.
con_clr is a packed-nibble color for the console box (high = border, low = background). txt_clr is also packed; the high nibble sets the text foreground color, and the low nibble sets the background color of the scroll-position overlay that appears when the cursor is inside the console.
GConsolePrint accepts printf-style format strings and appends the result to the console’s internal buffer. The view auto-scrolls to show the latest output when the scroll position was already at the bottom. Users can scroll with the mouse wheel, and pressing Space while the console is focused jumps back to the bottom.
Managing Elements
These utility functions apply to any element type regardless of whichGCreate* call was used to create it.
Deleting an element
id and sets the slot to NULL. Creating a new element at the same ID later is safe.
Showing and hiding
1 to show an element or 0 to hide it. Hidden elements are not rendered and do not receive input, but they remain allocated and their state is preserved.
Moving and resizing
Mouse hit test
1 if the mouse cursor is currently inside the element’s bounding box and the element is visible on the active screen, 0 otherwise. For checkboxes, the hit area extends to include the label text.