Files
wmaker/WINGs/Extras/wtabledelegates.c
T

523 lines
16 KiB
C
Raw Normal View History

2000-11-12 03:29:53 +00:00
#include <stdint.h>
#include <WINGs/WINGsP.h>
2000-11-12 03:29:53 +00:00
#include "wtableview.h"
2001-01-06 17:20:46 +00:00
#include "wtabledelegates.h"
2000-11-12 03:29:53 +00:00
typedef struct {
2009-08-20 00:59:40 +02:00
WMTableView *table;
WMFont *font;
GC gc;
GC selGC;
WMColor *textColor;
} StringData;
2001-01-02 14:17:26 +00:00
typedef struct {
2009-08-20 00:59:40 +02:00
WMTableView *table;
GC selGc;
2001-01-02 14:17:26 +00:00
} PixmapData;
2000-12-21 04:46:20 +00:00
typedef struct {
2009-08-20 00:59:40 +02:00
WMTextField *widget;
WMTableView *table;
WMFont *font;
GC gc;
GC selGC;
WMColor *textColor;
2000-12-21 04:46:20 +00:00
} StringEditorData;
typedef struct {
2009-08-20 00:59:40 +02:00
WMPopUpButton *widget;
WMTableView *table;
WMFont *font;
char **options;
int count;
GC gc;
GC selGC;
WMColor *textColor;
} EnumSelectorData;
2001-01-02 14:17:26 +00:00
typedef struct {
2009-08-20 00:59:40 +02:00
WMButton *widget;
WMTableView *table;
Bool state;
GC gc;
GC selGC;
2001-01-02 14:17:26 +00:00
} BooleanSwitchData;
static char *SelectionColor = "#bbbbcc";
2004-10-12 21:28:27 +00:00
static void
2009-08-20 00:59:40 +02:00
stringDraw(WMScreen * scr, Drawable d, GC gc, GC sgc, WMColor * textColor,
WMFont * font, void *data, WMRect rect, Bool selected)
2000-12-21 04:46:20 +00:00
{
2009-08-20 00:59:40 +02:00
int x, y;
XRectangle rects[1];
Display *dpy = WMScreenDisplay(scr);
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
x = rect.pos.x + 5;
y = rect.pos.y + (rect.size.height - WMFontHeight(font)) / 2;
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
rects[0].x = rect.pos.x + 1;
rects[0].y = rect.pos.y + 1;
rects[0].width = rect.size.width - 1;
rects[0].height = rect.size.height - 1;
XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (!selected) {
XFillRectangles(dpy, d, gc, rects, 1);
2002-10-08 08:26:06 +00:00
2009-08-20 00:59:40 +02:00
WMDrawString(scr, d, textColor, font, x, y, data, strlen(data));
} else {
XFillRectangles(dpy, d, sgc, rects, 1);
2002-10-08 08:26:06 +00:00
2009-08-20 00:59:40 +02:00
WMDrawString(scr, d, textColor, font, x, y, data, strlen(data));
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
XSetClipMask(dpy, gc, None);
2000-12-21 04:46:20 +00:00
}
2009-08-20 00:59:40 +02:00
static void pixmapDraw(WMScreen * scr, Drawable d, GC gc, GC sgc, WMPixmap * pixmap, WMRect rect, Bool selected)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
int x, y;
XRectangle rects[1];
Display *dpy = WMScreenDisplay(scr);
WMSize size;
rects[0].x = rect.pos.x + 1;
rects[0].y = rect.pos.y + 1;
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);
}
} 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);
}
}
XSetClipMask(dpy, gc, None);
2001-01-02 14:17:26 +00:00
}
/* ---------------------------------------------------------------------- */
2000-11-12 03:29:53 +00:00
2009-08-20 00:59:40 +02:00
static void SECellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2000-11-12 03:29:53 +00:00
{
2009-08-20 00:59:40 +02:00
StringEditorData *strdata = (StringEditorData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row), WMTableViewRectForCell(table, column, row), False);
}
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
static void selectedSECellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2000-12-21 04:46:20 +00:00
{
2009-08-20 00:59:40 +02:00
StringEditorData *strdata = (StringEditorData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row), WMTableViewRectForCell(table, column, row), True);
}
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
static void beginSECellEdit(WMTableColumnDelegate * self, WMTableColumn * column, int row)
2000-12-21 04:46:20 +00:00
{
2009-08-20 00:59:40 +02:00
StringEditorData *strdata = (StringEditorData *) self->data;
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
void *data = WMTableViewDataForCell(strdata->table, column, row);
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
WMSetTextFieldText(strdata->widget, (char *)data);
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y);
WMResizeWidget(strdata->widget, rect.size.width + 1, rect.size.height + 1);
2000-12-21 04:46:20 +00:00
2009-08-20 00:59:40 +02:00
WMMapWidget(strdata->widget);
2000-11-12 03:29:53 +00:00
}
2009-08-20 00:59:40 +02:00
static void endSECellEdit(WMTableColumnDelegate * self, WMTableColumn * column, int row)
{
2009-08-20 00:59:40 +02:00
StringEditorData *strdata = (StringEditorData *) self->data;
char *text;
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
WMUnmapWidget(strdata->widget);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
text = WMGetTextFieldText(strdata->widget);
WMSetTableViewDataForCell(strdata->table, column, row, (void *)text);
}
2000-11-12 03:29:53 +00:00
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView * parent)
2000-11-12 03:29:53 +00:00
{
2009-08-20 00:59:40 +02:00
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);
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;
delegate->beginCellEdit = beginSECellEdit;
delegate->endCellEdit = endSECellEdit;
return delegate;
}
/* ---------------------------------------------------------------------- */
2009-08-20 00:59:40 +02:00
static void ESCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
{
2009-08-20 00:59:40 +02:00
EnumSelectorData *strdata = (EnumSelectorData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2009-09-14 15:57:52 +02:00
uintptr_t i = (uintptr_t)WMTableViewDataForCell(table, column, row);
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
strdata->options[i], WMTableViewRectForCell(table, column, row), False);
}
2009-08-20 00:59:40 +02:00
static void selectedESCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
{
2009-08-20 00:59:40 +02:00
EnumSelectorData *strdata = (EnumSelectorData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2009-09-14 15:57:52 +02:00
uintptr_t i = (uintptr_t)WMTableViewDataForCell(table, column, row);
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
strdata->options[i], WMTableViewRectForCell(table, column, row), True);
}
2009-08-20 00:59:40 +02:00
static void beginESCellEdit(WMTableColumnDelegate * self, WMTableColumn * column, int row)
{
2009-08-20 00:59:40 +02:00
EnumSelectorData *strdata = (EnumSelectorData *) self->data;
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
2009-09-14 15:57:52 +02:00
uintptr_t data = (uintptr_t)WMTableViewDataForCell(strdata->table, column, row);
2009-08-20 00:59:40 +02:00
wassertr(data < strdata->count);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMSetPopUpButtonSelectedItem(strdata->widget, data);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y);
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height + 1);
2009-08-20 00:59:40 +02:00
WMMapWidget(strdata->widget);
}
2009-08-20 00:59:40 +02:00
static void endESCellEdit(WMTableColumnDelegate * self, WMTableColumn * column, int row)
{
2009-08-20 00:59:40 +02:00
EnumSelectorData *strdata = (EnumSelectorData *) self->data;
int option;
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
WMUnmapWidget(strdata->widget);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
option = WMGetPopUpButtonSelectedItem(strdata->widget);
WMSetTableViewDataForCell(strdata->table, column, row, (void *)(uintptr_t) option);
}
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView * parent)
{
2009-08-20 00:59:40 +02:00
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);
data->table = parent;
data->font = WMSystemFontOfSize(scr, 12);
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
data->textColor = WMBlackColor(scr);
data->count = 0;
data->options = NULL;
delegate->data = data;
delegate->drawCell = ESCellPainter;
delegate->drawSelectedCell = selectedESCellPainter;
delegate->beginCellEdit = beginESCellEdit;
delegate->endCellEdit = endESCellEdit;
return delegate;
2000-11-12 03:29:53 +00:00
}
2000-12-21 03:38:12 +00:00
2009-08-20 00:59:40 +02:00
void WTSetEnumSelectorOptions(WMTableColumnDelegate * delegate, char **options, int count)
{
2009-08-20 00:59:40 +02:00
EnumSelectorData *data = (EnumSelectorData *) delegate->data;
int i;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
for (i = 0; i < WMGetPopUpButtonNumberOfItems(data->widget); i++) {
WMRemovePopUpButtonItem(data->widget, 0);
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
data->options = options;
data->count = count;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
for (i = 0; i < count; i++) {
WMAddPopUpButtonItem(data->widget, options[i]);
}
}
2001-01-02 14:17:26 +00:00
/* ---------------------------------------------------------------------- */
2009-08-20 00:59:40 +02:00
static void BSCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
BooleanSwitchData *strdata = (BooleanSwitchData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2009-09-14 15:57:52 +02:00
uintptr_t i = (uintptr_t)WMTableViewDataForCell(table, column, row);
2009-08-20 00:59:40 +02:00
WMScreen *scr = WMWidgetScreen(table);
if (i) {
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);
}
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
static void selectedBSCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
BooleanSwitchData *strdata = (BooleanSwitchData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2009-09-14 15:57:52 +02:00
uintptr_t i = (uintptr_t)WMTableViewDataForCell(table, column, row);
2009-08-20 00:59:40 +02:00
WMScreen *scr = WMWidgetScreen(table);
if (i) {
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);
}
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
static void beginBSCellEdit(WMTableColumnDelegate * self, WMTableColumn * column, int row)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
BooleanSwitchData *strdata = (BooleanSwitchData *) self->data;
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
2009-09-14 15:57:52 +02:00
uintptr_t data = (uintptr_t)WMTableViewDataForCell(strdata->table, column, row);
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
WMSetButtonSelected(strdata->widget, data);
WMMoveWidget(strdata->widget, rect.pos.x + 1, rect.pos.y + 1);
WMResizeWidget(strdata->widget, rect.size.width - 1, rect.size.height - 1);
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
WMMapWidget(strdata->widget);
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
static void endBSCellEdit(WMTableColumnDelegate * self, WMTableColumn * column, int row)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
BooleanSwitchData *strdata = (BooleanSwitchData *) self->data;
int value;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
value = WMGetButtonSelected(strdata->widget);
WMSetTableViewDataForCell(strdata->table, column, row, (void *)(uintptr_t) value);
WMUnmapWidget(strdata->widget);
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView * parent)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
WMScreen *scr = WMWidgetScreen(parent);
BooleanSwitchData *data = wmalloc(sizeof(BooleanSwitchData));
WMColor *color;
data->widget = WMCreateSwitchButton(parent);
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);
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(color);
delegate->data = data;
delegate->drawCell = BSCellPainter;
delegate->drawSelectedCell = selectedBSCellPainter;
delegate->beginCellEdit = beginBSCellEdit;
delegate->endCellEdit = endBSCellEdit;
return delegate;
2001-01-02 14:17:26 +00:00
}
/* ---------------------------------------------------------------------- */
2000-12-21 03:38:12 +00:00
2009-08-20 00:59:40 +02:00
static void SCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
{
2009-08-20 00:59:40 +02:00
StringData *strdata = (StringData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row), WMTableViewRectForCell(table, column, row), False);
}
2009-08-20 00:59:40 +02:00
static void selectedSCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
{
2009-08-20 00:59:40 +02:00
StringData *strdata = (StringData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
WMTableViewDataForCell(table, column, row), WMTableViewRectForCell(table, column, row), True);
}
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *WTCreateStringDelegate(WMTableView * parent)
{
2009-08-20 00:59:40 +02:00
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;
delegate->beginCellEdit = NULL;
delegate->endCellEdit = NULL;
return delegate;
}
2001-01-02 14:17:26 +00:00
/* ---------------------------------------------------------------------- */
2009-08-20 00:59:40 +02:00
static void PCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
StringData *strdata = (StringData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
pixmapDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC,
(WMPixmap *) WMTableViewDataForCell(table, column, row),
WMTableViewRectForCell(table, column, row), False);
}
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
static void selectedPCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
StringData *strdata = (StringData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
pixmapDraw(WMWidgetScreen(table), d,
strdata->gc, strdata->selGC,
(WMPixmap *) WMTableViewDataForCell(table, column, row),
WMTableViewRectForCell(table, column, row), True);
}
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView * table)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
WMScreen *scr = WMWidgetScreen(table);
StringData *data = wmalloc(sizeof(StringData));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
data->table = table;
data->gc = WMColorGC(WMWhiteColor(scr));
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
delegate->data = data;
delegate->drawCell = PCellPainter;
delegate->drawSelectedCell = selectedPCellPainter;
delegate->beginCellEdit = NULL;
delegate->endCellEdit = NULL;
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
return delegate;
2001-01-02 14:17:26 +00:00
}
/* ---------------------------------------------------------------------- */
2009-08-20 00:59:40 +02:00
static void drawPSCell(WMTableColumnDelegate * self, Drawable d, WMTableColumn * column, int row, Bool selected)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
StringData *strdata = (StringData *) self->data;
WMTableView *table = WMGetTableColumnTableView(column);
void **data;
WMPixmap *pix;
char *str;
WMRect rect;
WMSize size;
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
data = WMTableViewDataForCell(table, column, row);
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
str = (char *)data[0];
pix = (WMPixmap *) data[1];
2001-01-02 14:17:26 +00:00
2009-08-20 00:59:40 +02:00
rect = WMTableViewRectForCell(table, column, row);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (pix) {
int owidth = rect.size.width;
2002-10-08 08:26:06 +00:00
2009-08-20 00:59:40 +02:00
size = WMGetPixmapSize(pix);
rect.size.width = size.width;
2002-10-08 08:26:06 +00:00
2009-08-20 00:59:40 +02:00
pixmapDraw(WMWidgetScreen(table),
WMViewXID(WMGetTableViewDocumentView(table)),
strdata->gc, strdata->selGC, pix, rect, selected);
2002-10-08 08:26:06 +00:00
2009-08-20 00:59:40 +02:00
rect.pos.x += size.width - 1;
rect.size.width = owidth - size.width + 1;
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
stringDraw(WMWidgetScreen(table), d, strdata->gc, strdata->selGC,
strdata->textColor, strdata->font, str, rect, selected);
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
static void PSCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
drawPSCell(self, d, column, row, False);
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
static void selectedPSCellPainter(WMTableColumnDelegate * self, WMTableColumn * column, int row, Drawable d)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
drawPSCell(self, d, column, row, True);
2001-01-02 14:17:26 +00:00
}
2009-08-20 00:59:40 +02:00
WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView * parent)
2001-01-02 14:17:26 +00:00
{
2009-08-20 00:59:40 +02:00
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;
delegate->beginCellEdit = NULL;
delegate->endCellEdit = NULL;
return delegate;
2001-01-02 14:17:26 +00:00
}