A pool of checkboxes that shows the settings of whichever entry a list has selected needs to change what each box says without destroying it. n_gui_checkbox_set_label() does that and n_gui_checkbox_get_label() reads it back; neither touches a widget that is not a checkbox, and a label longer than the widget holds is cut, not overrun.
Headless: the builtin font needs no display.
#define ALLEGRO_UNSTABLE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
if (!ok) {
} else {
}
}
int opt = 0;
while ((opt = getopt(argc, argv, "V:")) != -1) {
if (opt == 'V') {
} else {
return -1;
}
}
return 0;
}
int main(
int argc,
char** argv) {
char longer[1024];
fprintf(stderr, "Usage: %s [-V LOG_LEVEL]\n", argv[0]);
return 2;
}
if (!al_init() || !al_init_font_addon()) {
return 1;
}
ALLEGRO_FONT*
font = al_create_builtin_font();
return 1;
}
memset(longer, 'x', sizeof(longer) - 1);
longer[sizeof(longer) - 1] = '\0';
expect_true(
"a button is not a checkbox: its label is left alone",
{
}
}
void process_args(int argc, char **argv)
static void expect_true(const char *label, int cond)
FONT * font
the default 8x8 font, valid after allegro_init()
void n_gui_set_display_size(N_GUI_CTX *ctx, float w, float h)
set the display (viewport) size so global scrollbars can be computed.
#define N_GUI_ALIGN_LEFT
left aligned text
void n_gui_label_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set label text content
int n_gui_add_label(N_GUI_CTX *ctx, int window_id, const char *text, float x, float y, float w, float h, int align)
Add a static text label.
int n_gui_add_window(N_GUI_CTX *ctx, const char *title, float x, float y, float w, float h)
Add a new pseudo-window to the context.
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
Create a new GUI context.
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
void n_gui_checkbox_set_label(N_GUI_CTX *ctx, int widget_id, const char *label)
Replace the text drawn beside a checkbox.
const char * n_gui_checkbox_get_label(N_GUI_CTX *ctx, int widget_id)
What a checkbox says.
int n_gui_checkbox_is_checked(N_GUI_CTX *ctx, int widget_id)
check if a checkbox widget is checked
const char * n_gui_button_get_label(N_GUI_CTX *ctx, int widget_id)
What a button says.
int n_gui_add_checkbox(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, int initial_checked, void(*on_toggle)(int, int, void *), void *user_data)
Add a checkbox widget.
#define N_GUI_SHAPE_RECT
rectangle shape (default)
int n_gui_add_button(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, int shape, void(*on_click)(int, void *), void *user_data)
Add a button widget to a window.
const char * n_gui_label_get_text(N_GUI_CTX *ctx, int widget_id)
What a label says now.
The top-level GUI context that holds all windows.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL ).
#define LOG_NOTICE
normal but significant condition
#define LOG_INFO
informational
Common headers and low-level functions & define.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.