mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-02 22:25:48 +01:00
changed indentation to use spaces only
This commit is contained in:
@@ -12,61 +12,65 @@ static int col2[20];
|
||||
|
||||
static char *options[] = {
|
||||
"Option1",
|
||||
"Option2",
|
||||
"Option3",
|
||||
"Option4",
|
||||
"Option5"
|
||||
"Option2",
|
||||
"Option3",
|
||||
"Option4",
|
||||
"Option5"
|
||||
};
|
||||
|
||||
|
||||
int numberOfRows(WMTableViewDelegate *self, WMTableView *table)
|
||||
int
|
||||
numberOfRows(WMTableViewDelegate *self, WMTableView *table)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
||||
void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
|
||||
void*
|
||||
valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
/*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/
|
||||
int i;
|
||||
if (col1[0] == 0) {
|
||||
for (i = 0; i < 20; i++) {
|
||||
char buf[128];
|
||||
for (i = 0; i < 20; i++) {
|
||||
char buf[128];
|
||||
|
||||
sprintf(buf, "Test row %i", i);
|
||||
sprintf(buf, "Test row %i", i);
|
||||
|
||||
col1[i] = wstrdup(buf);
|
||||
col2[i] = 0;
|
||||
}
|
||||
col1[i] = wstrdup(buf);
|
||||
col2[i] = 0;
|
||||
}
|
||||
}
|
||||
if ((int)WMGetTableColumnId(column) == 1)
|
||||
return col1[row];
|
||||
return col1[row];
|
||||
else
|
||||
return (void*)col2[row];
|
||||
return (void*)col2[row];
|
||||
}
|
||||
|
||||
|
||||
void setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
|
||||
void *data)
|
||||
void
|
||||
setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
|
||||
void *data)
|
||||
{
|
||||
if ((int)WMGetTableColumnId(column) == 1)
|
||||
col1[row] = data;
|
||||
col1[row] = data;
|
||||
else
|
||||
col2[row] = (int)data;
|
||||
col2[row] = (int)data;
|
||||
}
|
||||
|
||||
|
||||
static WMTableViewDelegate delegate = {
|
||||
NULL,
|
||||
numberOfRows,
|
||||
valueForCell,
|
||||
setValueForCell
|
||||
numberOfRows,
|
||||
valueForCell,
|
||||
setValueForCell
|
||||
};
|
||||
|
||||
|
||||
|
||||
void clickedTable(WMWidget *w, void *self)
|
||||
{
|
||||
void
|
||||
clickedTable(WMWidget *w, void *self)
|
||||
{
|
||||
int row = WMGetTableViewClickedRow((WMTableView*)self);
|
||||
|
||||
WMEditTableViewRow(self, row);
|
||||
@@ -82,17 +86,17 @@ main(int argc, char **argv)
|
||||
WMTableView *table;
|
||||
WMTableColumn *col;
|
||||
WMTableColumnDelegate *colDeleg;
|
||||
|
||||
|
||||
WMInitializeApplication("test", &argc, argv);
|
||||
|
||||
|
||||
scr = WMOpenScreen(NULL);
|
||||
|
||||
XSynchronize(WMScreenDisplay(scr), 1);
|
||||
|
||||
|
||||
win = WMCreateWindow(scr, "eweq");
|
||||
WMResizeWidget(win, 400, 200);
|
||||
WMMapWidget(win);
|
||||
|
||||
|
||||
table = WMCreateTableView(win);
|
||||
WMSetTableViewHasHorizontalScroller(table, 0);
|
||||
WMSetViewExpandsToParent(WMWidgetView(table), 10, 10, 10, 10);
|
||||
@@ -101,12 +105,12 @@ main(int argc, char **argv)
|
||||
WMSetTableViewHeaderHeight(table, 20);
|
||||
WMSetTableViewDelegate(table, &delegate);
|
||||
WMSetTableViewAction(table, clickedTable, table);
|
||||
|
||||
|
||||
colDeleg = WTCreateStringEditorDelegate(table);
|
||||
|
||||
|
||||
col = WMCreateTableColumn("Group");
|
||||
WMSetTableColumnWidth(col, 180);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
WMSetTableColumnId(col, (void*)1);
|
||||
|
||||
@@ -115,15 +119,15 @@ main(int argc, char **argv)
|
||||
|
||||
col = WMCreateTableColumn("Package");
|
||||
WMSetTableColumnWidth(col, 140);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
WMSetTableColumnId(col, (void*)2);
|
||||
WMSetTableColumnId(col, (void*)2);
|
||||
|
||||
colDeleg = WTCreateBooleanSwitchDelegate(table);
|
||||
|
||||
col = WMCreateTableColumn("Bool");
|
||||
WMSetTableColumnWidth(col, 50);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
WMSetTableColumnId(col, (void*)2);
|
||||
|
||||
@@ -133,3 +137,4 @@ main(int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct {
|
||||
WMTableView *table;
|
||||
WMFont *font;
|
||||
char **options;
|
||||
int count;
|
||||
int count;
|
||||
GC gc;
|
||||
GC selGC;
|
||||
WMColor *textColor;
|
||||
@@ -57,9 +57,9 @@ static char *SelectionColor = "#bbbbcc";
|
||||
|
||||
|
||||
|
||||
static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
WMColor *textColor, WMFont *font, void *data,
|
||||
WMRect rect, Bool selected)
|
||||
static void
|
||||
stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, WMColor *textColor,
|
||||
WMFont *font, void *data, WMRect rect, Bool selected)
|
||||
{
|
||||
int x, y;
|
||||
XRectangle rects[1];
|
||||
@@ -73,26 +73,27 @@ static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
rects[0].width = rect.size.width-1;
|
||||
rects[0].height = rect.size.height-1;
|
||||
XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted);
|
||||
|
||||
|
||||
if (!selected) {
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
} else {
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
}
|
||||
|
||||
|
||||
XSetClipMask(dpy, gc, None);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
WMPixmap *pixmap, WMRect rect, Bool selected)
|
||||
static void
|
||||
pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, WMPixmap *pixmap,
|
||||
WMRect rect, Bool selected)
|
||||
{
|
||||
int x, y;
|
||||
XRectangle rects[1];
|
||||
@@ -104,29 +105,29 @@ static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
rects[0].width = rect.size.width-1;
|
||||
rects[0].height = rect.size.height-1;
|
||||
XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted);
|
||||
|
||||
|
||||
if (!selected) {
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
} else {
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XSetClipMask(dpy, gc, None);
|
||||
}
|
||||
|
||||
@@ -135,38 +136,40 @@ static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
|
||||
|
||||
|
||||
static void SECellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
SECellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedSECellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedSECellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
static void beginSECellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
beginSECellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
void *data = WMTableViewDataForCell(strdata->table, column, row);
|
||||
|
||||
@@ -178,35 +181,36 @@ static void beginSECellEdit(WMTableColumnDelegate *self,
|
||||
}
|
||||
|
||||
|
||||
static void endSECellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
endSECellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
char *text;
|
||||
|
||||
WMUnmapWidget(strdata->widget);
|
||||
|
||||
|
||||
text = WMGetTextFieldText(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)text);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
StringEditorData *data = wmalloc(sizeof(StringEditorData));
|
||||
|
||||
|
||||
data->widget = WMCreateTextField(parent);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->textColor = WMBlackColor(scr);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = SECellPainter;
|
||||
delegate->drawSelectedCell = selectedSECellPainter;
|
||||
@@ -221,47 +225,49 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void ESCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
ESCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedESCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedESCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
static void beginESCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
beginESCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
int data = (int)WMTableViewDataForCell(strdata->table, column, row);
|
||||
|
||||
wassertr(data < strdata->count);
|
||||
|
||||
|
||||
WMSetPopUpButtonSelectedItem(strdata->widget, data);
|
||||
|
||||
|
||||
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y);
|
||||
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+1);
|
||||
|
||||
@@ -269,29 +275,30 @@ static void beginESCellEdit(WMTableColumnDelegate *self,
|
||||
}
|
||||
|
||||
|
||||
static void endESCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
endESCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
int option;
|
||||
|
||||
WMUnmapWidget(strdata->widget);
|
||||
|
||||
|
||||
option = WMGetPopUpButtonSelectedItem(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)option);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
EnumSelectorData *data = wmalloc(sizeof(EnumSelectorData));
|
||||
|
||||
|
||||
data->widget = WMCreatePopUpButton(parent);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
@@ -299,7 +306,7 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
data->textColor = WMBlackColor(scr);
|
||||
data->count = 0;
|
||||
data->options = NULL;
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = ESCellPainter;
|
||||
delegate->drawSelectedCell = selectedESCellPainter;
|
||||
@@ -310,23 +317,24 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
}
|
||||
|
||||
|
||||
void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
char **options, int count)
|
||||
void
|
||||
WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate, char **options,
|
||||
int count)
|
||||
{
|
||||
EnumSelectorData *data = (EnumSelectorData*)delegate->data;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0;
|
||||
i < WMGetPopUpButtonNumberOfItems(data->widget);
|
||||
i++) {
|
||||
WMRemovePopUpButtonItem(data->widget, 0);
|
||||
i < WMGetPopUpButtonNumberOfItems(data->widget);
|
||||
i++) {
|
||||
WMRemovePopUpButtonItem(data->widget, 0);
|
||||
}
|
||||
|
||||
|
||||
data->options = options;
|
||||
data->count = count;
|
||||
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
WMAddPopUpButtonItem(data->widget, options[i]);
|
||||
WMAddPopUpButtonItem(data->widget, options[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,51 +342,53 @@ void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static void BSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
BSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
|
||||
|
||||
if (i) {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
} else {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void selectedBSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedBSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
|
||||
|
||||
if (i) {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
} else {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
}
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void beginBSCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
beginBSCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
int data = (int)WMTableViewDataForCell(strdata->table, column, row);
|
||||
|
||||
@@ -390,19 +400,20 @@ static void beginBSCellEdit(WMTableColumnDelegate *self,
|
||||
}
|
||||
|
||||
|
||||
static void endBSCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
endBSCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
int value;
|
||||
|
||||
|
||||
value = WMGetButtonSelected(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)value);
|
||||
WMUnmapWidget(strdata->widget);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
@@ -410,20 +421,20 @@ WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
WMColor *color;
|
||||
|
||||
data->widget = WMCreateSwitchButton(parent);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
WMSetButtonText(data->widget, NULL);
|
||||
WMSetButtonImagePosition(data->widget, WIPImageOnly);
|
||||
WMSetButtonImage(data->widget, NULL);
|
||||
WMSetButtonAltImage(data->widget, WMGetSystemPixmap(scr, WSICheckMark));
|
||||
|
||||
|
||||
data->table = parent;
|
||||
color = WMCreateNamedColor(scr, SelectionColor, False);
|
||||
WMSetWidgetBackgroundColor(data->widget, color);
|
||||
WMSetWidgetBackgroundColor(data->widget, color);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(color);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = BSCellPainter;
|
||||
delegate->drawSelectedCell = selectedBSCellPainter;
|
||||
@@ -437,46 +448,49 @@ WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void SCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
SCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateStringDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
StringData *data = wmalloc(sizeof(StringData));
|
||||
|
||||
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->textColor = WMBlackColor(scr);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = SCellPainter;
|
||||
delegate->drawSelectedCell = selectedSCellPainter;
|
||||
@@ -490,44 +504,47 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void PCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
PCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
pixmapDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedPCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedPCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
pixmapDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table)
|
||||
WMTableColumnDelegate*
|
||||
WTCreatePixmapDelegate(WMTableView *table)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
StringData *data = wmalloc(sizeof(StringData));
|
||||
|
||||
|
||||
data->table = table;
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = PCellPainter;
|
||||
delegate->drawSelectedCell = selectedPCellPainter;
|
||||
@@ -541,8 +558,9 @@ WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void drawPSCell(WMTableColumnDelegate *self, Drawable d,
|
||||
WMTableColumn *column, int row, Bool selected)
|
||||
static void
|
||||
drawPSCell(WMTableColumnDelegate *self, Drawable d, WMTableColumn *column,
|
||||
int row, Bool selected)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
@@ -554,57 +572,60 @@ static void drawPSCell(WMTableColumnDelegate *self, Drawable d,
|
||||
|
||||
data = WMTableViewDataForCell(table, column, row);
|
||||
|
||||
str = (char*)data[0];
|
||||
str = (char*)data[0];
|
||||
pix = (WMPixmap*)data[1];
|
||||
|
||||
rect = WMTableViewRectForCell(table, column, row);
|
||||
|
||||
|
||||
if (pix) {
|
||||
int owidth = rect.size.width;
|
||||
int owidth = rect.size.width;
|
||||
|
||||
size = WMGetPixmapSize(pix);
|
||||
rect.size.width = size.width;
|
||||
size = WMGetPixmapSize(pix);
|
||||
rect.size.width = size.width;
|
||||
|
||||
pixmapDraw(WMWidgetScreen(table),
|
||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||
strdata->gc, strdata->selGC, pix, rect,
|
||||
selected);
|
||||
pixmapDraw(WMWidgetScreen(table),
|
||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||
strdata->gc, strdata->selGC, pix, rect,
|
||||
selected);
|
||||
|
||||
rect.pos.x += size.width-1;
|
||||
rect.size.width = owidth-size.width+1;
|
||||
rect.pos.x += size.width-1;
|
||||
rect.size.width = owidth-size.width+1;
|
||||
}
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d, strdata->gc, strdata->selGC,
|
||||
strdata->textColor, strdata->font, str, rect, selected);
|
||||
}
|
||||
|
||||
|
||||
static void PSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
PSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
drawPSCell(self, d, column, row, False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedPSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedPSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
drawPSCell(self, d, column, row, True);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreatePixmapStringDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
StringData *data = wmalloc(sizeof(StringData));
|
||||
|
||||
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->textColor = WMBlackColor(scr);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = PSCellPainter;
|
||||
delegate->drawSelectedCell = selectedPSCellPainter;
|
||||
|
||||
@@ -14,7 +14,7 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table);
|
||||
|
||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table);
|
||||
void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
char **options, int count);
|
||||
char **options, int count);
|
||||
|
||||
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,98 +18,98 @@ extern const char *WMTableViewSelectionDidChangeNotification;
|
||||
typedef struct WMTableColumnDelegate {
|
||||
void *data;
|
||||
void (*drawCell)(struct WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
void (*drawSelectedCell)(struct WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
|
||||
void (*beginCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row);
|
||||
int row);
|
||||
void (*endCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row);
|
||||
int row);
|
||||
} WMTableColumnDelegate;
|
||||
|
||||
|
||||
typedef struct W_TableViewDelegate {
|
||||
void *data;
|
||||
int (*numberOfRows)(struct W_TableViewDelegate *self,
|
||||
WMTableView *table);
|
||||
void *(*valueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row);
|
||||
void (*setValueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row, void *value);
|
||||
int (*numberOfRows)(struct W_TableViewDelegate *self,
|
||||
WMTableView *table);
|
||||
void *(*valueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row);
|
||||
void (*setValueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row, void *value);
|
||||
} WMTableViewDelegate;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
WMTableColumn *WMCreateTableColumn(char *title);
|
||||
|
||||
void WMSetTableColumnWidth(WMTableColumn *column, unsigned width);
|
||||
|
||||
void WMSetTableColumnConstraints(WMTableColumn *column,
|
||||
unsigned minWidth, unsigned maxWidth);
|
||||
|
||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||
WMTableColumnDelegate *delegate);
|
||||
void WMSetTableColumnConstraints(WMTableColumn *column,
|
||||
unsigned minWidth, unsigned maxWidth);
|
||||
|
||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||
WMTableColumnDelegate *delegate);
|
||||
|
||||
|
||||
WMTableView *WMGetTableColumnTableView(WMTableColumn *column);
|
||||
|
||||
|
||||
void WMSetTableColumnId(WMTableColumn *column, void *id);
|
||||
|
||||
void *WMGetTableColumnId(WMTableColumn *column);
|
||||
|
||||
|
||||
|
||||
WMTableView *WMCreateTableView(WMWidget *parent);
|
||||
|
||||
|
||||
|
||||
void WMSetTableViewDataSource(WMTableView *table, void *source);
|
||||
|
||||
void *WMGetTableViewDataSource(WMTableView *table);
|
||||
|
||||
void WMSetTableViewHeaderHeight(WMTableView *table, unsigned height);
|
||||
|
||||
|
||||
void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column);
|
||||
|
||||
void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate);
|
||||
|
||||
void WMSetTableViewAction(WMTableView *table, WMAction *action,
|
||||
void *clientData);
|
||||
void WMSetTableViewAction(WMTableView *table, WMAction *action,
|
||||
void *clientData);
|
||||
|
||||
void *WMGetTableViewClickedColumn(WMTableView *table);
|
||||
|
||||
int WMGetTableViewClickedRow(WMTableView *table);
|
||||
|
||||
WMArray *WMGetTableViewSelectedRows(WMTableView *table);
|
||||
|
||||
|
||||
WMView *WMGetTableViewDocumentView(WMTableView *table);
|
||||
|
||||
void WMEditTableViewRow(WMTableView *table, int row);
|
||||
|
||||
void WMSelectTableViewRow(WMTableView *table, int row);
|
||||
|
||||
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
|
||||
void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row, void *data);
|
||||
|
||||
WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row, void *data);
|
||||
|
||||
WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
|
||||
void WMSetTableViewBackgroundColor(WMTableView *table, WMColor *color);
|
||||
|
||||
void WMSetTableViewGridColor(WMTableView *table, WMColor *color);
|
||||
|
||||
void WMSetTableViewRowHeight(WMTableView *table, int height);
|
||||
|
||||
void WMReloadTableView(WMTableView *table);
|
||||
|
||||
void WMSetTableViewRowHeight(WMTableView *table, int height);
|
||||
|
||||
void WMReloadTableView(WMTableView *table);
|
||||
|
||||
void WMNoteTableViewNumberOfRowsChanged(WMTableView *table);
|
||||
|
||||
|
||||
void WMScrollTableViewRowToVisible(WMTableView *table, int row);
|
||||
|
||||
|
||||
void WMSetTableViewHasHorizontalScroller(WMTableView *tPtr, Bool flag);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user