3 #include <WINGs/WINGs.h>
4 #include "wtableview.h"
5 #include "wtabledelegates.h"
8 static char *col1
[20] = {0};
12 static char *options
[] = {
21 int numberOfRows(WMTableViewDelegate
*self
, WMTableView
*table
)
27 void *valueForCell(WMTableViewDelegate
*self
, WMTableColumn
*column
, int row
)
29 /*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/
32 for (i
= 0; i
< 20; i
++) {
37 if ((int)WMGetTableColumnId(column
) == 1)
40 return (void*)col2
[row
];
44 void setValueForCell(WMTableViewDelegate
*self
, WMTableColumn
*column
, int row
,
47 if ((int)WMGetTableColumnId(column
) == 1)
50 col2
[row
] = (int)data
;
54 static WMTableViewDelegate delegate
= {
63 void clickedTable(WMWidget
*w
, void *self
)
65 int row
= WMGetTableViewClickedRow((WMTableView
*)self
);
67 WMEditTableViewRow(self
, row
);
73 main(int argc
, char **argv
)
79 WMTableColumnDelegate
*colDeleg
;
81 WMInitializeApplication("test", &argc
, argv
);
83 scr
= WMOpenScreen(NULL
);
86 win
= WMCreateWindow(scr
, "eweq");
87 WMResizeWidget(win
, 400, 200);
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);
125 WMRealizeWidget(win
);
126 WMScreenMainLoop(scr
);