changed indentation to use spaces only
[wmaker-crm.git] / WINGs / Extras / test.c
blobe1c0ef2fafc5d4eb3f80918c2de5c08ae187ee2b
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
23 numberOfRows(WMTableViewDelegate *self, WMTableView *table)
25 return 20;
29 void*
30 valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
32 /*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/
33 int i;
34 if (col1[0] == 0) {
35 for (i = 0; i < 20; i++) {
36 char buf[128];
38 sprintf(buf, "Test row %i", i);
40 col1[i] = wstrdup(buf);
41 col2[i] = 0;
44 if ((int)WMGetTableColumnId(column) == 1)
45 return col1[row];
46 else
47 return (void*)col2[row];
51 void
52 setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
53 void *data)
55 if ((int)WMGetTableColumnId(column) == 1)
56 col1[row] = data;
57 else
58 col2[row] = (int)data;
62 static WMTableViewDelegate delegate = {
63 NULL,
64 numberOfRows,
65 valueForCell,
66 setValueForCell
71 void
72 clickedTable(WMWidget *w, void *self)
74 int row = WMGetTableViewClickedRow((WMTableView*)self);
76 WMEditTableViewRow(self, row);
81 int
82 main(int argc, char **argv)
84 WMScreen *scr;
85 WMWindow *win;
86 WMTableView *table;
87 WMTableColumn *col;
88 WMTableColumnDelegate *colDeleg;
90 WMInitializeApplication("test", &argc, argv);
92 scr = WMOpenScreen(NULL);
94 XSynchronize(WMScreenDisplay(scr), 1);
96 win = WMCreateWindow(scr, "eweq");
97 WMResizeWidget(win, 400, 200);
98 WMMapWidget(win);
100 table = WMCreateTableView(win);
101 WMSetTableViewHasHorizontalScroller(table, 0);
102 WMSetViewExpandsToParent(WMWidgetView(table), 10, 10, 10, 10);
103 WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
104 /*WMSetTableViewGridColor(table, WMGrayColor(scr));*/
105 WMSetTableViewHeaderHeight(table, 20);
106 WMSetTableViewDelegate(table, &delegate);
107 WMSetTableViewAction(table, clickedTable, table);
109 colDeleg = WTCreateStringEditorDelegate(table);
111 col = WMCreateTableColumn("Group");
112 WMSetTableColumnWidth(col, 180);
113 WMAddTableViewColumn(table, col);
114 WMSetTableColumnDelegate(col, colDeleg);
115 WMSetTableColumnId(col, (void*)1);
117 colDeleg = WTCreateEnumSelectorDelegate(table);
118 WTSetEnumSelectorOptions(colDeleg, options, 5);
120 col = WMCreateTableColumn("Package");
121 WMSetTableColumnWidth(col, 140);
122 WMAddTableViewColumn(table, col);
123 WMSetTableColumnDelegate(col, colDeleg);
124 WMSetTableColumnId(col, (void*)2);
126 colDeleg = WTCreateBooleanSwitchDelegate(table);
128 col = WMCreateTableColumn("Bool");
129 WMSetTableColumnWidth(col, 50);
130 WMAddTableViewColumn(table, col);
131 WMSetTableColumnDelegate(col, colDeleg);
132 WMSetTableColumnId(col, (void*)2);
134 WMMapWidget(table);
135 WMRealizeWidget(win);
136 WMScreenMainLoop(scr);
138 return 0;