- put back wmksize(), wmkrange() and wmkpoint() as functions instead of macros
[wmaker-crm.git] / WINGs / Extras / test.c
blobd3ebae0b9f286bab4170771557dd3bc02b9e49da
3 #include <WINGs/WINGs.h>
4 #include "wtableview.h"
5 #include "wtabledelegates.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 WMScreen *scr;
76 WMWindow *win;
77 WMTableView *table;
78 WMTableColumn *col;
79 WMTableColumnDelegate *colDeleg;
81 WMInitializeApplication("test", &argc, argv);
83 scr = WMOpenScreen(NULL);
86 win = WMCreateWindow(scr, "eweq");
87 WMResizeWidget(win, 400, 200);
88 WMMapWidget(win);
90 table = WMCreateTableView(win);
91 WMResizeWidget(table, 400, 200);
92 WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
93 /*WMSetTableViewGridColor(table, WMGrayColor(scr));*/
94 WMSetTableViewHeaderHeight(table, 20);
95 WMSetTableViewDelegate(table, &delegate);
96 WMSetTableViewAction(table, clickedTable, table);
98 colDeleg = WTCreateStringEditorDelegate(table);
100 col = WMCreateTableColumn("Group");
101 WMSetTableColumnWidth(col, 180);
102 WMAddTableViewColumn(table, col);
103 WMSetTableColumnDelegate(col, colDeleg);
104 WMSetTableColumnId(col, (void*)1);
106 colDeleg = WTCreateEnumSelectorDelegate(table);
107 WTSetEnumSelectorOptions(colDeleg, options, 5);
109 col = WMCreateTableColumn("Package");
110 WMSetTableColumnWidth(col, 140);
111 WMAddTableViewColumn(table, col);
112 WMSetTableColumnDelegate(col, colDeleg);
113 WMSetTableColumnId(col, (void*)2);
115 colDeleg = WTCreateBooleanSwitchDelegate(table);
117 col = WMCreateTableColumn("Bool");
118 WMSetTableColumnWidth(col, 50);
119 WMAddTableViewColumn(table, col);
120 WMSetTableColumnDelegate(col, colDeleg);
121 WMSetTableColumnId(col, (void*)2);
124 WMMapWidget(table);
125 WMRealizeWidget(win);
126 WMScreenMainLoop(scr);