foxygit / doom Log in
commit 0755f5ac88fa3ea3074e1d1e46b5e101de59abdb
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Sep 26 23:47:27 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Sep 26 23:47:27 2006 +0000

    Add TXT_AddWidgets for adding multiple widgets to a table.

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 672
---
 textscreen/txt_table.c | 27 +++++++++++++++++++++++++++
 textscreen/txt_table.h |  1 +
 2 files changed, 28 insertions(+)

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), ...);