2 #include <WINGs/WINGs.h>
5 #include "wtableview.h"
6 #include "wtabledelegates.h"
8 static char *col1
[20] = { 0 };
12 static char *options
[] = {
20 int numberOfRows(WMTableViewDelegate
* self
, WMTableView
* table
)
25 void *valueForCell(WMTableViewDelegate
* self
, WMTableColumn
* column
, int row
)
27 /*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column); */
30 for (i
= 0; i
< 20; i
++) {
33 sprintf(buf
, "Test row %i", i
);
35 col1
[i
] = wstrdup(buf
);
39 if ((int)(uintptr_t) WMGetTableColumnId(column
) == 1)
42 return (void *)(uintptr_t) col2
[row
];
45 void setValueForCell(WMTableViewDelegate
* self
, WMTableColumn
* column
, int row
, void *data
)
47 if ((int)(uintptr_t) WMGetTableColumnId(column
) == 1)
50 col2
[row
] = (int)(uintptr_t) data
;
53 static WMTableViewDelegate delegate
= {
60 void clickedTable(WMWidget
* w
, void *self
)
62 int row
= WMGetTableViewClickedRow((WMTableView
*) self
);
64 WMEditTableViewRow(self
, row
);
67 int main(int argc
, char **argv
)
73 WMTableColumnDelegate
*colDeleg
;
75 WMInitializeApplication("test", &argc
, argv
);
77 scr
= WMOpenScreen(NULL
);
79 XSynchronize(WMScreenDisplay(scr
), 1);
81 win
= WMCreateWindow(scr
, "eweq");
82 WMResizeWidget(win
, 400, 200);
85 table
= WMCreateTableView(win
);
86 WMSetTableViewHasHorizontalScroller(table
, 0);
87 WMSetViewExpandsToParent(WMWidgetView(table
), 10, 10, 10, 10);
88 WMSetTableViewBackgroundColor(table
, WMWhiteColor(scr
));
89 /*WMSetTableViewGridColor(table, WMGrayColor(scr)); */
90 WMSetTableViewHeaderHeight(table
, 20);
91 WMSetTableViewDelegate(table
, &delegate
);
92 WMSetTableViewAction(table
, clickedTable
, table
);
94 colDeleg
= WTCreateStringEditorDelegate(table
);
96 col
= WMCreateTableColumn("Group");
97 WMSetTableColumnWidth(col
, 180);
98 WMAddTableViewColumn(table
, col
);
99 WMSetTableColumnDelegate(col
, colDeleg
);
100 WMSetTableColumnId(col
, (void *)1);
102 colDeleg
= WTCreateEnumSelectorDelegate(table
);
103 WTSetEnumSelectorOptions(colDeleg
, options
, 5);
105 col
= WMCreateTableColumn("Package");
106 WMSetTableColumnWidth(col
, 140);
107 WMAddTableViewColumn(table
, col
);
108 WMSetTableColumnDelegate(col
, colDeleg
);
109 WMSetTableColumnId(col
, (void *)2);
111 colDeleg
= WTCreateBooleanSwitchDelegate(table
);
113 col
= WMCreateTableColumn("Bool");
114 WMSetTableColumnWidth(col
, 50);
115 WMAddTableViewColumn(table
, col
);
116 WMSetTableColumnDelegate(col
, colDeleg
);
117 WMSetTableColumnId(col
, (void *)2);
120 WMRealizeWidget(win
);
121 WMScreenMainLoop(scr
);