textscreen: Add TXT_MakeTable().
When creating a table widget is is often convenient to be able to create and populate it in a single function call. It's possible to do this with "horizontal boxes" already but there wasn't a more generic mechanism for making a table. So add one as TXT_MakeTable().
This commit is contained in:
parent
77ad7dc5f8
commit
1d2fe63a94
2 changed files with 43 additions and 0 deletions
|
|
@ -906,6 +906,37 @@ txt_table_t *TXT_NewTable(int columns)
|
|||
return table;
|
||||
}
|
||||
|
||||
// Alternative to TXT_NewTable() that allows a list of widgets to be
|
||||
// provided in its arguments.
|
||||
txt_table_t *TXT_MakeTable(int columns, TXT_UNCAST_ARG(first_widget), ...)
|
||||
{
|
||||
TXT_CAST_ARG(txt_widget_t, first_widget);
|
||||
txt_table_t *table;
|
||||
va_list args;
|
||||
|
||||
table = TXT_NewTable(columns);
|
||||
TXT_AddWidget(table, first_widget);
|
||||
|
||||
va_start(args, TXT_UNCAST_ARG_NAME(first_widget));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
txt_widget_t *widget;
|
||||
widget = va_arg(args, txt_widget_t *);
|
||||
|
||||
if (widget == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TXT_AddWidget(table, widget);
|
||||
}
|
||||
|
||||
va_end(args);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
// Create a horizontal table from a list of widgets.
|
||||
|
||||
txt_table_t *TXT_NewHorizBox(TXT_UNCAST_ARG(first_widget), ...)
|
||||
|
|
|
|||
|
|
@ -100,6 +100,18 @@ void TXT_InitTable(txt_table_t *table, int columns);
|
|||
|
||||
txt_table_t *TXT_NewTable(int columns);
|
||||
|
||||
/**
|
||||
* Create a new table and populate it with provided widgets.
|
||||
*
|
||||
* The arguments to this function are variable. Each argument must be a
|
||||
* pointer to a widget, and the list is terminated with a NULL.
|
||||
*
|
||||
* @param columns The number of columns in the new table.
|
||||
* @return Pointer to the new table structure.
|
||||
*/
|
||||
|
||||
txt_table_t *TXT_MakeTable(int columns, TXT_UNCAST_ARG(first_widget), ...);
|
||||
|
||||
/**
|
||||
* Create a table containing the specified widgets packed horizontally,
|
||||
* from left to right.
|
||||
|
|
|
|||
Loading…
Reference in a new issue