3 #include <WINGs/WINGs.h>
5 #include "wtableview.h"
6 #include "wtabledelegates.h"
9 static char *col1
[20] = {0};
13 static char *options
[] = {
22 int numberOfRows(WMTableViewDelegate
*self
, WMTableView
*table
)
28 void *valueForCell(WMTableViewDelegate
*self
, WMTableColumn
*column
, int row
)
30 /*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/
33 for (i
= 0; i
< 20; i
++) {
36 sprintf(buf
, "Test row %i", i
);
38 col1
[i
] = wstrdup(buf
);
42 if ((int)WMGetTableColumnId(column
) == 1)
45 return (void*)col2
[row
];
49 void setValueForCell(WMTableViewDelegate
*self
, WMTableColumn
*column
, int row
,
52 if ((int)WMGetTableColumnId(column
) == 1)
55 col2
[row
] = (int)data
;
59 static WMTableViewDelegate delegate
= {
68 void clickedTable(WMWidget
*w
, void *self
)
70 int row
= WMGetTableViewClickedRow((WMTableView
*)self
);
72 WMEditTableViewRow(self
, row
);
78 main(int argc
, char **argv
)
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);
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);
130 WMRealizeWidget(win
);
131 WMScreenMainLoop(scr
);