From 65ed2a3208db93eef0f25f5d9c046c77cb7eb980 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Feb 2008 22:43:11 +0000 Subject: Update chocolate-setup to the new screen mode config system. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1042 --- textscreen/txt_table.c | 19 +++++++++++++++---- textscreen/txt_table.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'textscreen') diff --git a/textscreen/txt_table.c b/textscreen/txt_table.c index 8b31af24..29798906 100644 --- a/textscreen/txt_table.c +++ b/textscreen/txt_table.c @@ -33,14 +33,18 @@ #include "txt_strut.h" #include "txt_table.h" -static void TXT_TableDestructor(TXT_UNCAST_ARG(table)) +// Remove all entries from a table + +void TXT_ClearTable(TXT_UNCAST_ARG(table)) { TXT_CAST_ARG(txt_table_t, table); int i; // Free all widgets + // Skip over the first (num_columns) widgets in the array, as these + // are the column struts used to control column width - for (i=0; inum_widgets; ++i) + for (i=table->columns; inum_widgets; ++i) { if (table->widgets[i] != NULL) { @@ -48,9 +52,16 @@ static void TXT_TableDestructor(TXT_UNCAST_ARG(table)) } } - // Free table resources + // Shrink the table to just the column strut widgets + + table->num_widgets = table->columns; +} + +static void TXT_TableDestructor(TXT_UNCAST_ARG(table)) +{ + TXT_CAST_ARG(txt_table_t, table); - free(table->widgets); + TXT_ClearTable(table); } static int TableRows(txt_table_t *table) diff --git a/textscreen/txt_table.h b/textscreen/txt_table.h index c3a3c5a8..d42e9adb 100644 --- a/textscreen/txt_table.h +++ b/textscreen/txt_table.h @@ -53,6 +53,7 @@ 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), ...); +void TXT_ClearTable(TXT_UNCAST_ARG(table)); #endif /* #ifndef TXT_TABLE_T */ -- cgit v1.2.3