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
++) {
35 sprintf(buf
, "Test row %i", i
);
37 col1
[i
] = wstrdup(buf
);
41 if ((int)WMGetTableColumnId(column
) == 1)
44 return (void*)col2
[row
];
48 void setValueForCell(WMTableViewDelegate
*self
, WMTableColumn
*column
, int row
,
51 if ((int)WMGetTableColumnId(column
) == 1)
54 col2
[row
] = (int)data
;
58 static WMTableViewDelegate delegate
= {
67 void clickedTable(WMWidget
*w
, void *self
)
69 int row
= WMGetTableViewClickedRow((WMTableView
*)self
);
71 WMEditTableViewRow(self
, row
);
77 main(int argc
, char **argv
)
83 WMTableColumnDelegate
*colDeleg
;
85 WMInitializeApplication("test", &argc
, argv
);
87 scr
= WMOpenScreen(NULL
);
89 XSynchronize(WMScreenDisplay(scr
), 1);
91 win
= WMCreateWindow(scr
, "eweq");
92 WMResizeWidget(win
, 400, 200);
95 table
= WMCreateTableView(win
);
96 WMSetViewExpandsToParent(WMWidgetView(table
), 10, 10, 10, 10);
97 WMSetTableViewBackgroundColor(table
, WMWhiteColor(scr
));
98 /*WMSetTableViewGridColor(table, WMGrayColor(scr));*/
99 WMSetTableViewHeaderHeight(table
, 20);
100 WMSetTableViewDelegate(table
, &delegate
);
101 WMSetTableViewAction(table
, clickedTable
, table
);
103 colDeleg
= WTCreateStringEditorDelegate(table
);
105 col
= WMCreateTableColumn("Group");
106 WMSetTableColumnWidth(col
, 180);
107 WMAddTableViewColumn(table
, col
);
108 WMSetTableColumnDelegate(col
, colDeleg
);
109 WMSetTableColumnId(col
, (void*)1);
111 colDeleg
= WTCreateEnumSelectorDelegate(table
);
112 WTSetEnumSelectorOptions(colDeleg
, options
, 5);
114 col
= WMCreateTableColumn("Package");
115 WMSetTableColumnWidth(col
, 140);
116 WMAddTableViewColumn(table
, col
);
117 WMSetTableColumnDelegate(col
, colDeleg
);
118 WMSetTableColumnId(col
, (void*)2);
120 colDeleg
= WTCreateBooleanSwitchDelegate(table
);
122 col
= WMCreateTableColumn("Bool");
123 WMSetTableColumnWidth(col
, 50);
124 WMAddTableViewColumn(table
, col
);
125 WMSetTableColumnDelegate(col
, colDeleg
);
126 WMSetTableColumnId(col
, (void*)2);
129 WMRealizeWidget(win
);
130 WMScreenMainLoop(scr
);