summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--textscreen/txt_table.c27
-rw-r--r--textscreen/txt_table.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/textscreen/txt_table.c b/textscreen/txt_table.c
index f6f38e53..e23ff843 100644
--- a/textscreen/txt_table.c
+++ b/textscreen/txt_table.c
@@ -164,6 +164,33 @@ void TXT_AddWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget))
++table->num_widgets;
}
+// Add multiple widgets to a table.
+
+void TXT_AddWidgets(TXT_UNCAST_ARG(table), ...)
+{
+ TXT_CAST_ARG(txt_table_t, table);
+ va_list args;
+ txt_widget_t *widget;
+
+ va_start(args, TXT_UNCAST_ARG_NAME(table));
+
+ // Keep adding widgets until a NULL is reached.
+
+ for (;;)
+ {
+ widget = va_arg(args, txt_widget_t *);
+
+ if (widget == NULL)
+ {
+ break;
+ }
+
+ TXT_AddWidget(table, widget);
+ }
+
+ va_end(args);
+}
+
static int SelectableWidget(txt_table_t *table, int x, int y)
{
txt_widget_t *widget;
diff --git a/textscreen/txt_table.h b/textscreen/txt_table.h
index 2effc85b..c3a3c5a8 100644
--- a/textscreen/txt_table.h
+++ b/textscreen/txt_table.h
@@ -50,6 +50,7 @@ txt_table_t *TXT_NewTable(int columns);
txt_table_t *TXT_NewHorizBox(TXT_UNCAST_ARG(first_widget), ...);
void TXT_InitTable(txt_table_t *table, int columns);
void TXT_AddWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget));
+void TXT_AddWidgets(TXT_UNCAST_ARG(table), ...);
int TXT_SelectWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget));
void TXT_SetColumnWidths(TXT_UNCAST_ARG(table), ...);