| 1 |
/* |
| 2 |
* Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk> |
| 3 |
* Rights to this code are as documented in doc/LICENSE. |
| 4 |
* |
| 5 |
* Table rendering class. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef ATHEME_TABLE_H |
| 10 |
#define ATHEME_TABLE_H |
| 11 |
|
| 12 |
typedef struct { |
| 13 |
object_t parent; |
| 14 |
mowgli_list_t rows; |
| 15 |
} table_t; |
| 16 |
|
| 17 |
typedef struct { |
| 18 |
int id; |
| 19 |
mowgli_list_t cells; |
| 20 |
} table_row_t; |
| 21 |
|
| 22 |
typedef struct { |
| 23 |
int width; /* only if first row. */ |
| 24 |
char *name; |
| 25 |
char *value; |
| 26 |
} table_cell_t; |
| 27 |
|
| 28 |
/* |
| 29 |
* Creates a new table object. Use object_unref() to destroy it. |
| 30 |
*/ |
| 31 |
E table_t *table_new(const char *fmt, ...) PRINTFLIKE(1, 2); |
| 32 |
|
| 33 |
/* |
| 34 |
* Renders a table, each line going to callback(). |
| 35 |
*/ |
| 36 |
E void table_render(table_t *t, void (*callback)(const char *line, void *data), void *data); |
| 37 |
|
| 38 |
/* |
| 39 |
* Associates a value with a row. |
| 40 |
*/ |
| 41 |
E void table_cell_associate(table_row_t *r, const char *name, const char *value); |
| 42 |
|
| 43 |
/* |
| 44 |
* Associates a row with a table. |
| 45 |
*/ |
| 46 |
E table_row_t *table_row_new(table_t *t); |
| 47 |
|
| 48 |
#endif |