Add "make doc" target to run Doxygen, and add a Doxyfile. Add @file tags to start...
[chocolate-doom.git] / textscreen / txt_table.h
blob0e7fbe949ebc3c8fedf20329a3d26f0323b779e9
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // Copyright(C) 2006 Simon Howard
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 // 02111-1307, USA.
22 #ifndef TXT_TABLE_H
23 #define TXT_TABLE_H
25 /**
26 * @file txt_table.h
28 * Table widget.
31 /**
32 * Table widget.
34 * A table is a widget that contains other widgets. It may have
35 * multiple columns, in which case the child widgets are laid out
36 * in a grid. Columns automatically grow as necessary, although
37 * minimum column widths can be set using @ref TXT_SetColumnWidths.
39 * To create a new table, use @ref TXT_NewTable. It is also
40 * possible to use @ref TXT_NewHorizBox to create a table, specifying
41 * widgets to place inside a horizontal list. A vertical list is
42 * possible simply by creating a table containing a single column.
45 typedef struct txt_table_s txt_table_t;
47 #include "txt_widget.h"
49 struct txt_table_s
51 txt_widget_t widget;
53 // Widgets in this table
54 // The widget at (x,y) in the table is widgets[columns * y + x]
56 txt_widget_t **widgets;
57 int num_widgets;
59 // Number of columns
61 int columns;
63 // Currently selected
65 int selected_x;
66 int selected_y;
69 extern txt_widget_class_t txt_table_class;
71 void TXT_InitTable(txt_table_t *table, int columns);
73 /**
74 * Create a new table.
76 * @param columns The number of columns in the new table.
77 * @return Pointer to the new table structure.
80 txt_table_t *TXT_NewTable(int columns);
82 /**
83 * Create a table containing the specified widgets packed horizontally,
84 * from left to right.
86 * The arguments to this function are variable. Each argument must
87 * be a pointer to a widget, and the list is terminated with a
88 * NULL.
90 * @return Pointer to the new table structure.
93 txt_table_t *TXT_NewHorizBox(TXT_UNCAST_ARG(first_widget), ...);
95 /**
96 * Get the currently selected widget within a table.
98 * This function will recurse through subtables if necessary.
100 * @param table The table.
101 * @return Pointer to the widget that is currently selected.
104 txt_widget_t *TXT_GetSelectedWidget(TXT_UNCAST_ARG(table));
107 * Add a widget to a table.
109 * Widgets are added to tables horizontally, from left to right.
110 * For example, for a table with three columns, the first call
111 * to this function will add a widget to the first column, the second
112 * call to the second column, the third call to the third column,
113 * and the fourth will return to the first column, starting a new
114 * row.
116 * For adding many widgets, it may be easier to use
117 * @ref TXT_AddWidgets.
119 * @param table The table.
120 * @param widget The widget to add.
123 void TXT_AddWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget));
126 * Add multiple widgets to a table.
128 * Widgets are added as described in the documentation for the
129 * @ref TXT_AddWidget function. This function adds multiple
130 * widgets. The number of arguments is variable, and the argument
131 * list must be terminated by a NULL pointer.
133 * @param table The table.
136 void TXT_AddWidgets(TXT_UNCAST_ARG(table), ...);
139 * Select the given widget that is contained within the specified
140 * table.
142 * This function will recursively search through subtables if
143 * necessary.
145 * @param table The table.
146 * @param widget The widget to select.
147 * @return Non-zero (true) if it has been selected,
148 * or zero (false) if it was not found within
149 * this table.
152 int TXT_SelectWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget));
155 * Set the widths of the columns of the table.
157 * The arguments to this function are variable, and correspond
158 * to the number of columns in the table. For example, if a table
159 * has five columns, the width of each of the five columns must be
160 * specified.
162 * The width values are in number of characters.
164 * Note that this function only sets the minimum widths for columns;
165 * if the columns contain widgets that are wider than the widths
166 * specified, they will be larger.
168 * @param table The table.
171 void TXT_SetColumnWidths(TXT_UNCAST_ARG(table), ...);
174 * Remove all widgets from a table.
176 * @param table The table.
179 void TXT_ClearTable(TXT_UNCAST_ARG(table));
181 #endif /* #ifndef TXT_TABLE_T */