#include #include static int SortString(const void *p1, const void *p2) { const AG_TableCell *c1 = p1; const AG_TableCell *c2 = p2; return (strcoll(c1->data.s, c2->data.s)); } static int SortInt(const void *p1, const void *p2) { const AG_TableCell *c1 = p1; const AG_TableCell *c2 = p2; return (c1->data.i - c2->data.i); } int main(int argc, char *argv[]) { AG_Window *win; AG_Table *tbl; /* Initialize Agar. */ if (AG_InitCore("table1", 0) == -1 || AG_InitVideo(320, 240, 32, AG_VIDEO_RESIZABLE) == -1) return (1); /* Create a new window. */ win = AG_WindowNew(0); /* Create a new table that expands to fill the window. */ tbl = AG_TableNew(win, AG_TABLE_EXPAND); /* Insert the columns. */ AG_TableAddCol(tbl, "Item", "", SortString); AG_TableAddCol(tbl, "Count", NULL, SortInt); /* Insert the rows. */ AG_TableAddRow(tbl, "%s:%i", "Foo", 10); AG_TableAddRow(tbl, "%s:%i", "Bar", 100); AG_TableAddRow(tbl, "%s:%i", "Baz", 1000); /* Show the window and enter event loop. */ AG_WindowShow(win); AG_EventLoop(); return (0); }