- Finished moving to the new proplist handling code in WINGs.
[wmaker-crm.git] / WINGs / Extras / test.c
blob767ba40c8d7ba2df95843c4557e3cbd2c951dd4d
3 #include <WINGs/WINGs.h>
4 #include <stdio.h>
5 #include "wtableview.h"
6 #include "wtabledelegates.h"
9 static char *col1[20] = {0};
10 static int col2[20];
13 static char *options[] = {
14 "Option1",
15 "Option2",
16 "Option3",
17 "Option4",
18 "Option5"
22 int numberOfRows(WMTableViewDelegate *self, WMTableView *table)
24 return 20;
28 void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
30 /*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/
31 int i;
32 if (col1[0] == 0) {
33 for (i = 0; i < 20; i++) {
34 char buf[128];
36 sprintf(buf, "Test row %i", i);
38 col1[i] = wstrdup(buf);
39 col2[i] = 0;
42 if ((int)WMGetTableColumnId(column) == 1)
43 return col1[row];
44 else
45 return (void*)col2[row];
49 void setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
50 void *data)
52 if ((int)WMGetTableColumnId(column) == 1)
53 col1[row] = data;
54 else
55 col2[row] = (int)data;
59 static WMTableViewDelegate delegate = {
60 NULL,
61 numberOfRows,
62 valueForCell,
63 setValueForCell
68 void clickedTable(WMWidget *w, void *self)
70 int row = WMGetTableViewClickedRow((WMTableView*)self);
72 WMEditTableViewRow(self, row);
77 int
78 main(int argc, char **argv)
80 WMScreen *scr;
81 WMWindow *win;
82 WMTableView *table;
83 WMTableColumn *col;
84 WMTableColumnDelegate *colDeleg;
86 WMInitializeApplication("test", &argc, argv);
88 scr = WMOpenScreen(NULL);
90 XSynchronize(WMScreenDisplay(scr), 1);
92 win = WMCreateWindow(scr, "eweq");
93 WMResizeWidget(win, 400, 200);
94 WMMapWidget(win);
96 table = WMCreateTableView(win);
97 WMSetViewExpandsToParent(WMWidgetView(table), 10, 10, 10, 10);
98 WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
99 /*WMSetTableViewGridColor(table, WMGrayColor(scr));*/
100 WMSetTableViewHeaderHeight(table, 20);
101 WMSetTableViewDelegate(table, &delegate);
102 WMSetTableViewAction(table, clickedTable, table);
104 colDeleg = WTCreateStringEditorDelegate(table);
106 col = WMCreateTableColumn("Group");
107 WMSetTableColumnWidth(col, 180);
108 WMAddTableViewColumn(table, col);
109 WMSetTableColumnDelegate(col, colDeleg);
110 WMSetTableColumnId(col, (void*)1);
112 colDeleg = WTCreateEnumSelectorDelegate(table);
113 WTSetEnumSelectorOptions(colDeleg, options, 5);
115 col = WMCreateTableColumn("Package");
116 WMSetTableColumnWidth(col, 140);
117 WMAddTableViewColumn(table, col);
118 WMSetTableColumnDelegate(col, colDeleg);
119 WMSetTableColumnId(col, (void*)2);
121 colDeleg = WTCreateBooleanSwitchDelegate(table);
123 col = WMCreateTableColumn("Bool");
124 WMSetTableColumnWidth(col, 50);
125 WMAddTableViewColumn(table, col);
126 WMSetTableColumnDelegate(col, colDeleg);
127 WMSetTableColumnId(col, (void*)2);
129 WMMapWidget(table);
130 WMRealizeWidget(win);
131 WMScreenMainLoop(scr);
133 return 0;