diff options
author | Simon Howard | 2006-09-26 23:47:27 +0000 |
---|---|---|
committer | Simon Howard | 2006-09-26 23:47:27 +0000 |
commit | 0755f5ac88fa3ea3074e1d1e46b5e101de59abdb (patch) | |
tree | 670dd573c4fc35d7a8406e8c312de02685fc5a38 | |
parent | 8ebd88a5ce9e8e5f41879e34311ba86c8b10c362 (diff) | |
download | chocolate-doom-0755f5ac88fa3ea3074e1d1e46b5e101de59abdb.tar.gz chocolate-doom-0755f5ac88fa3ea3074e1d1e46b5e101de59abdb.tar.bz2 chocolate-doom-0755f5ac88fa3ea3074e1d1e46b5e101de59abdb.zip |
Add TXT_AddWidgets for adding multiple widgets to a table.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 672
-rw-r--r-- | textscreen/txt_table.c | 27 | ||||
-rw-r--r-- | textscreen/txt_table.h | 1 |
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), ...); |