fixed missed sgi cc compat bug
[wmaker-crm.git] / WINGs / Extras / test.c
blob5913416c504146e2db026f94f82ab69a1bbc4ce0
3 #include <WINGs.h>
4 #include "wtableview.h"
5 #include "tabledelegates.h"
8 static char *col1[20] = {0};
9 static int col2[20];
12 static char *options[] = {
13 "Option1",
14 "Option2",
15 "Option3",
16 "Option4",
17 "Option5"
21 int numberOfRows(WMTableViewDelegate *self, WMTableView *table)
23 return 20;
27 void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
29 WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);
30 int i;
31 if (col1[0] == 0) {
32 for (i = 0; i < 20; i++) {
33 col1[i] = "teste";
34 col2[i] = 0;
37 if ((int)WMGetTableColumnId(column) == 1)
38 return col1[row];
39 else
40 return (void*)col2[row];
44 void setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
45 void *data)
47 if ((int)WMGetTableColumnId(column) == 1)
48 col1[row] = data;
49 else
50 col2[row] = (int)data;
54 static WMTableViewDelegate delegate = {
55 NULL,
56 numberOfRows,
57 valueForCell,
58 setValueForCell
63 void clickedTable(WMWidget *w, void *self)
65 int row = WMGetTableViewClickedRow((WMTableView*)self);
67 WMEditTableViewRow(self, row);
73 main(int argc, char **argv)
75 Display *dpy = XOpenDisplay("");
76 WMScreen *scr;
77 WMWindow *win;
78 WMTableView *table;
79 WMTableColumn *col;
80 WMTableColumnDelegate *colDeleg;
82 WMInitializeApplication("test", &argc, argv);
86 dpy = XOpenDisplay("");
87 if (!dpy) {
88 exit(1);
91 scr = WMCreateScreen(dpy, DefaultScreen(dpy));
94 win = WMCreateWindow(scr, "eweq");
95 WMResizeWidget(win, 400, 200);
96 WMMapWidget(win);
98 table = WMCreateTableView(win);
99 WMResizeWidget(table, 400, 200);
100 WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
101 // WMSetTableViewGridColor(table, WMGrayColor(scr));
102 WMSetTableViewHeaderHeight(table, 20);
103 WMSetTableViewDelegate(table, &delegate);
104 WMSetTableViewAction(table, clickedTable, table);
106 colDeleg = WTCreateStringEditorDelegate(table);
108 col = WMCreateTableColumn("Group");
109 WMSetTableColumnWidth(col, 180);
110 WMAddTableViewColumn(table, col);
111 WMSetTableColumnDelegate(col, colDeleg);
112 WMSetTableColumnId(col, (void*)1);
114 colDeleg = WTCreateEnumSelectorDelegate(table);
115 WTSetEnumSelectorOptions(colDeleg, options, 5);
117 col = WMCreateTableColumn("Package");
118 WMSetTableColumnWidth(col, 140);
119 WMAddTableViewColumn(table, col);
120 WMSetTableColumnDelegate(col, colDeleg);
121 WMSetTableColumnId(col, (void*)2);
124 colDeleg = WTCreateBooleanSwitchDelegate(table);
126 col = WMCreateTableColumn("Bool");
127 WMSetTableColumnWidth(col, 50);
128 WMAddTableViewColumn(table, col);
129 WMSetTableColumnDelegate(col, colDeleg);
130 WMSetTableColumnId(col, (void*)2);
133 WMMapWidget(table);
134 WMRealizeWidget(win);
135 WMScreenMainLoop(scr);