mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 05:48:01 +01:00
various table widget updates
and fixed in misc other ones
This commit is contained in:
@@ -59,6 +59,8 @@ changes since wmaker 0.62.1:
|
|||||||
doesn't add "warning:" in the output message.
|
doesn't add "warning:" in the output message.
|
||||||
- added WMBox widget
|
- added WMBox widget
|
||||||
- added W_SetViewCursor()
|
- added W_SetViewCursor()
|
||||||
|
- made Extra widgets library
|
||||||
|
- added table widget in Extras library
|
||||||
- added WMGetConnectionUnsentData() (WMGetConnectionQueuedData() too as an
|
- added WMGetConnectionUnsentData() (WMGetConnectionQueuedData() too as an
|
||||||
alias).
|
alias).
|
||||||
- added WMSetConnectionCloseOnExec() to specify if the socket associated
|
- added WMSetConnectionCloseOnExec() to specify if the socket associated
|
||||||
@@ -83,6 +85,7 @@ changes since wmaker 0.62.1:
|
|||||||
apparently went away, but continued to use memory).
|
apparently went away, but continued to use memory).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
changes since wmaker 0.62.0:
|
changes since wmaker 0.62.0:
|
||||||
............................
|
............................
|
||||||
- added WMSetWidgetDefaultFont(), WMSetWidgetDefaultBoldFont()
|
- added WMSetWidgetDefaultFont(), WMSetWidgetDefaultBoldFont()
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ typedef struct {
|
|||||||
} StringData;
|
} StringData;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
WMTableView *table;
|
||||||
|
GC selGc;
|
||||||
|
} PixmapData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WMTextField *widget;
|
WMTextField *widget;
|
||||||
WMTableView *table;
|
WMTableView *table;
|
||||||
@@ -36,6 +43,17 @@ typedef struct {
|
|||||||
} EnumSelectorData;
|
} EnumSelectorData;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
WMButton *widget;
|
||||||
|
WMTableView *table;
|
||||||
|
Bool state;
|
||||||
|
GC gc;
|
||||||
|
} BooleanSwitchData;
|
||||||
|
|
||||||
|
|
||||||
|
static char *SelectionColor = "#bbbbcc";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void stringDraw(WMScreen *scr, Drawable d, GC gc,
|
static void stringDraw(WMScreen *scr, Drawable d, GC gc,
|
||||||
GC sgc, GC stgc, WMFont *font, void *data,
|
GC sgc, GC stgc, WMFont *font, void *data,
|
||||||
@@ -73,6 +91,49 @@ static void stringDraw(WMScreen *scr, Drawable d, GC gc,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void pixmapDraw(WMScreen *scr, Drawable d, GC gc,
|
||||||
|
WMPixmap *pixmap, WMRect rect, Bool selected)
|
||||||
|
{
|
||||||
|
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) {
|
||||||
|
XClearArea(dpy, d, rects[0].x, rects[0].y,
|
||||||
|
rects[0].width, rects[0].height,
|
||||||
|
False);
|
||||||
|
|
||||||
|
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, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XSetClipMask(dpy, gc, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -125,9 +186,10 @@ static void endSECellEdit(WMTableColumnDelegate *self,
|
|||||||
WMTableColumn *column, int row)
|
WMTableColumn *column, int row)
|
||||||
{
|
{
|
||||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
|
WMUnmapWidget(strdata->widget);
|
||||||
|
|
||||||
text = WMGetTextFieldText(strdata->widget);
|
text = WMGetTextFieldText(strdata->widget);
|
||||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)text);
|
WMSetTableViewDataForCell(strdata->table, column, row, (void*)text);
|
||||||
}
|
}
|
||||||
@@ -145,8 +207,8 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
|
|||||||
0, 0);
|
0, 0);
|
||||||
data->table = parent;
|
data->table = parent;
|
||||||
data->font = WMSystemFontOfSize(scr, 12);
|
data->font = WMSystemFontOfSize(scr, 12);
|
||||||
data->selGc = WMColorGC(WMDarkGrayColor(scr));
|
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||||
data->selTextGc = WMColorGC(WMWhiteColor(scr));
|
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||||
data->gc = WMColorGC(WMBlackColor(scr));
|
data->gc = WMColorGC(WMBlackColor(scr));
|
||||||
|
|
||||||
delegate->data = data;
|
delegate->data = data;
|
||||||
@@ -168,7 +230,7 @@ static void ESCellPainter(WMTableColumnDelegate *self,
|
|||||||
{
|
{
|
||||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||||
WMTableView *table = WMGetTableColumnTableView(column);
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
int i = WMTableViewDataForCell(table, column, row);
|
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||||
|
|
||||||
stringDraw(WMWidgetScreen(table),
|
stringDraw(WMWidgetScreen(table),
|
||||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
@@ -184,7 +246,7 @@ static void selectedESCellPainter(WMTableColumnDelegate *self,
|
|||||||
{
|
{
|
||||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||||
WMTableView *table = WMGetTableColumnTableView(column);
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
int i = WMTableViewDataForCell(table, column, row);
|
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||||
|
|
||||||
stringDraw(WMWidgetScreen(table),
|
stringDraw(WMWidgetScreen(table),
|
||||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
@@ -206,8 +268,8 @@ static void beginESCellEdit(WMTableColumnDelegate *self,
|
|||||||
|
|
||||||
WMSetPopUpButtonSelectedItem(strdata->widget, data);
|
WMSetPopUpButtonSelectedItem(strdata->widget, data);
|
||||||
|
|
||||||
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y-1);
|
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y);
|
||||||
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+2);
|
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+1);
|
||||||
|
|
||||||
WMMapWidget(strdata->widget);
|
WMMapWidget(strdata->widget);
|
||||||
}
|
}
|
||||||
@@ -217,9 +279,10 @@ static void endESCellEdit(WMTableColumnDelegate *self,
|
|||||||
WMTableColumn *column, int row)
|
WMTableColumn *column, int row)
|
||||||
{
|
{
|
||||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
|
||||||
int option;
|
int option;
|
||||||
|
|
||||||
|
WMUnmapWidget(strdata->widget);
|
||||||
|
|
||||||
option = WMGetPopUpButtonSelectedItem(strdata->widget);
|
option = WMGetPopUpButtonSelectedItem(strdata->widget);
|
||||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)option);
|
WMSetTableViewDataForCell(strdata->table, column, row, (void*)option);
|
||||||
}
|
}
|
||||||
@@ -237,8 +300,8 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
|||||||
0, 0);
|
0, 0);
|
||||||
data->table = parent;
|
data->table = parent;
|
||||||
data->font = WMSystemFontOfSize(scr, 12);
|
data->font = WMSystemFontOfSize(scr, 12);
|
||||||
data->selGc = WMColorGC(WMDarkGrayColor(scr));
|
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||||
data->selTextGc = WMColorGC(WMWhiteColor(scr));
|
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||||
data->gc = WMColorGC(WMBlackColor(scr));
|
data->gc = WMColorGC(WMBlackColor(scr));
|
||||||
data->count = 0;
|
data->count = 0;
|
||||||
data->options = NULL;
|
data->options = NULL;
|
||||||
@@ -274,6 +337,108 @@ void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
static void BSCellPainter(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||||
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
|
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||||
|
WMScreen *scr = WMWidgetScreen(table);
|
||||||
|
|
||||||
|
if (i) {
|
||||||
|
pixmapDraw(scr, WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->gc, WMGetSystemPixmap(scr, WSICheckMark),
|
||||||
|
WMTableViewRectForCell(table, column, row), False);
|
||||||
|
} else {
|
||||||
|
pixmapDraw(scr, WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->gc, NULL,
|
||||||
|
WMTableViewRectForCell(table, column, row), False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void selectedBSCellPainter(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||||
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
|
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||||
|
WMScreen *scr = WMWidgetScreen(table);
|
||||||
|
|
||||||
|
if (i) {
|
||||||
|
pixmapDraw(scr, WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->gc, WMGetSystemPixmap(scr, WSICheckMark),
|
||||||
|
WMTableViewRectForCell(table, column, row), True);
|
||||||
|
} else {
|
||||||
|
pixmapDraw(scr, WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->gc, NULL,
|
||||||
|
WMTableViewRectForCell(table, column, row), True);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void beginBSCellEdit(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||||
|
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||||
|
int data = (int)WMTableViewDataForCell(strdata->table, column, row);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
WMMapWidget(strdata->widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void endBSCellEdit(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
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 *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(color);
|
||||||
|
|
||||||
|
delegate->data = data;
|
||||||
|
delegate->drawCell = BSCellPainter;
|
||||||
|
delegate->drawSelectedCell = selectedBSCellPainter;
|
||||||
|
delegate->beginCellEdit = beginBSCellEdit;
|
||||||
|
delegate->endCellEdit = endBSCellEdit;
|
||||||
|
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
@@ -315,8 +480,8 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
|||||||
|
|
||||||
data->table = parent;
|
data->table = parent;
|
||||||
data->font = WMSystemFontOfSize(scr, 12);
|
data->font = WMSystemFontOfSize(scr, 12);
|
||||||
data->selGc = WMColorGC(WMDarkGrayColor(scr));
|
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||||
data->selTextGc = WMColorGC(WMWhiteColor(scr));
|
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||||
data->gc = WMColorGC(WMBlackColor(scr));
|
data->gc = WMColorGC(WMBlackColor(scr));
|
||||||
|
|
||||||
delegate->data = data;
|
delegate->data = data;
|
||||||
@@ -327,3 +492,134 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
|||||||
|
|
||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
static void PCellPainter(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
StringData *strdata = (StringData*)self->data;
|
||||||
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
|
|
||||||
|
pixmapDraw(WMWidgetScreen(table),
|
||||||
|
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->selGc,
|
||||||
|
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||||
|
WMTableViewRectForCell(table, column, row),
|
||||||
|
False);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void selectedPCellPainter(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
StringData *strdata = (StringData*)self->data;
|
||||||
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
|
|
||||||
|
pixmapDraw(WMWidgetScreen(table),
|
||||||
|
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->selGc,
|
||||||
|
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||||
|
WMTableViewRectForCell(table, column, row),
|
||||||
|
True);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table)
|
||||||
|
{
|
||||||
|
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||||
|
WMScreen *scr = WMWidgetScreen(table);
|
||||||
|
StringData *data = wmalloc(sizeof(StringData));
|
||||||
|
|
||||||
|
data->table = table;
|
||||||
|
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||||
|
|
||||||
|
delegate->data = data;
|
||||||
|
delegate->drawCell = PCellPainter;
|
||||||
|
delegate->drawSelectedCell = selectedPCellPainter;
|
||||||
|
delegate->beginCellEdit = NULL;
|
||||||
|
delegate->endCellEdit = NULL;
|
||||||
|
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
static void drawPSCell(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row, Bool selected)
|
||||||
|
{
|
||||||
|
StringData *strdata = (StringData*)self->data;
|
||||||
|
WMTableView *table = WMGetTableColumnTableView(column);
|
||||||
|
void **data;
|
||||||
|
WMPixmap *pix;
|
||||||
|
char *str;
|
||||||
|
WMRect rect;
|
||||||
|
WMSize size;
|
||||||
|
|
||||||
|
data = WMTableViewDataForCell(table, column, row);
|
||||||
|
|
||||||
|
str = (char*)data[0];
|
||||||
|
pix = (WMPixmap*)data[1];
|
||||||
|
|
||||||
|
rect = WMTableViewRectForCell(table, column, row);
|
||||||
|
|
||||||
|
if (pix) {
|
||||||
|
int owidth = rect.size.width;
|
||||||
|
|
||||||
|
size = WMGetPixmapSize(pix);
|
||||||
|
rect.size.width = size.width;
|
||||||
|
|
||||||
|
pixmapDraw(WMWidgetScreen(table),
|
||||||
|
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->selGc, pix, rect,
|
||||||
|
selected);
|
||||||
|
|
||||||
|
rect.pos.x += size.width-1;
|
||||||
|
rect.size.width = owidth-size.width+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stringDraw(WMWidgetScreen(table),
|
||||||
|
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||||
|
strdata->gc, strdata->selGc, strdata->selTextGc, strdata->font,
|
||||||
|
str, rect, selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void PSCellPainter(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
drawPSCell(self, column, row, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void selectedPSCellPainter(WMTableColumnDelegate *self,
|
||||||
|
WMTableColumn *column, int row)
|
||||||
|
{
|
||||||
|
drawPSCell(self, column, row, True);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||||
|
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||||
|
data->gc = WMColorGC(WMBlackColor(scr));
|
||||||
|
|
||||||
|
delegate->data = data;
|
||||||
|
delegate->drawCell = PSCellPainter;
|
||||||
|
delegate->drawSelectedCell = selectedPSCellPainter;
|
||||||
|
delegate->beginCellEdit = NULL;
|
||||||
|
delegate->endCellEdit = NULL;
|
||||||
|
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,9 +6,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table);
|
||||||
WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *table);
|
WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *table);
|
||||||
|
WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent);
|
||||||
|
|
||||||
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table);
|
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table);
|
||||||
|
|
||||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table);
|
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table);
|
||||||
|
void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||||
|
char **options, int count);
|
||||||
|
|
||||||
|
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ static WMTableViewDelegate delegate = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void selectedRowObserver(void *self, WMNotification *notif)
|
void clickedTable(WMWidget *w, void *self)
|
||||||
{
|
{
|
||||||
int row = (int)WMGetNotificationClientData(notif);
|
int row = WMGetTableViewClickedRow((WMTableView*)self);
|
||||||
|
|
||||||
WMEditTableViewRow(self, row);
|
WMEditTableViewRow(self, row);
|
||||||
}
|
}
|
||||||
@@ -98,12 +98,10 @@ main(int argc, char **argv)
|
|||||||
table = WMCreateTableView(win);
|
table = WMCreateTableView(win);
|
||||||
WMResizeWidget(table, 400, 200);
|
WMResizeWidget(table, 400, 200);
|
||||||
WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
|
WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
|
||||||
WMSetTableViewGridColor(table, WMGrayColor(scr));
|
// WMSetTableViewGridColor(table, WMGrayColor(scr));
|
||||||
WMSetTableViewHeaderHeight(table, 20);
|
WMSetTableViewHeaderHeight(table, 20);
|
||||||
WMSetTableViewDelegate(table, &delegate);
|
WMSetTableViewDelegate(table, &delegate);
|
||||||
WMAddNotificationObserver(selectedRowObserver, table,
|
WMSetTableViewAction(table, clickedTable, table);
|
||||||
WMTableViewRowWasSelectedNotification,
|
|
||||||
table);
|
|
||||||
|
|
||||||
colDeleg = WTCreateStringEditorDelegate(table);
|
colDeleg = WTCreateStringEditorDelegate(table);
|
||||||
|
|
||||||
@@ -123,6 +121,15 @@ main(int argc, char **argv)
|
|||||||
WMSetTableColumnId(col, (void*)2);
|
WMSetTableColumnId(col, (void*)2);
|
||||||
|
|
||||||
|
|
||||||
|
colDeleg = WTCreateBooleanSwitchDelegate(table);
|
||||||
|
|
||||||
|
col = WMCreateTableColumn("Bool");
|
||||||
|
WMSetTableColumnWidth(col, 50);
|
||||||
|
WMAddTableViewColumn(table, col);
|
||||||
|
WMSetTableColumnDelegate(col, colDeleg);
|
||||||
|
WMSetTableColumnId(col, (void*)2);
|
||||||
|
|
||||||
|
|
||||||
WMMapWidget(table);
|
WMMapWidget(table);
|
||||||
WMRealizeWidget(win);
|
WMRealizeWidget(win);
|
||||||
WMScreenMainLoop(scr);
|
WMScreenMainLoop(scr);
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
#include "wtableview.h"
|
#include "wtableview.h"
|
||||||
|
|
||||||
|
|
||||||
const char *WMTableViewRowWasSelectedNotification = "WMTableViewRowWasSelectedNotification";
|
const char *WMTableViewSelectionDidChangeNotification = "WMTableViewSelectionDidChangeNotification";
|
||||||
const char *WMTableViewRowWasUnselectedNotification = "WMTableViewRowWasUnselectedNotification";
|
|
||||||
|
|
||||||
|
|
||||||
struct W_TableColumn {
|
struct W_TableColumn {
|
||||||
@@ -30,6 +29,10 @@ struct W_TableColumn {
|
|||||||
|
|
||||||
static void handleResize(W_ViewDelegate *self, WMView *view);
|
static void handleResize(W_ViewDelegate *self, WMView *view);
|
||||||
|
|
||||||
|
static void rearrangeHeader(WMTableView *table);
|
||||||
|
|
||||||
|
static WMRange rowsInRect(WMTableView *table, WMRect rect);
|
||||||
|
|
||||||
|
|
||||||
WMTableColumn *WMCreateTableColumn(char *title)
|
WMTableColumn *WMCreateTableColumn(char *title)
|
||||||
{
|
{
|
||||||
@@ -74,7 +77,7 @@ void WMSetTableColumnWidth(WMTableColumn *column, unsigned width)
|
|||||||
column->width = WMAX(column->minWidth, WMIN(column->maxWidth, width));
|
column->width = WMAX(column->minWidth, WMIN(column->maxWidth, width));
|
||||||
|
|
||||||
if (column->table) {
|
if (column->table) {
|
||||||
handleResize(NULL, W_VIEW(column->table));
|
rearrangeHeader(column->table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,12 +146,19 @@ struct W_TableView {
|
|||||||
|
|
||||||
WMTableViewDelegate *delegate;
|
WMTableViewDelegate *delegate;
|
||||||
|
|
||||||
|
WMAction *action;
|
||||||
|
void *clientData;
|
||||||
|
|
||||||
|
void *clickedColumn;
|
||||||
|
int clickedRow;
|
||||||
|
|
||||||
int editingRow;
|
int editingRow;
|
||||||
|
|
||||||
unsigned headerHeight;
|
unsigned headerHeight;
|
||||||
|
|
||||||
unsigned rowHeight;
|
unsigned rowHeight;
|
||||||
|
|
||||||
|
unsigned dragging:1;
|
||||||
unsigned drawsGrid:1;
|
unsigned drawsGrid:1;
|
||||||
unsigned canSelectRow:1;
|
unsigned canSelectRow:1;
|
||||||
unsigned canSelectMultiRows:1;
|
unsigned canSelectMultiRows:1;
|
||||||
@@ -188,13 +198,13 @@ static void scrollObserver(void *self, WMNotification *notif)
|
|||||||
|
|
||||||
column = WMGetFromArray(table->columns, i);
|
column = WMGetFromArray(table->columns, i);
|
||||||
|
|
||||||
WMMoveWidget(column->titleW, x + rect.pos.x, 0);
|
WMMoveWidget(column->titleW, x - rect.pos.x, 0);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
WMView *splitter;
|
WMView *splitter;
|
||||||
|
|
||||||
splitter = WMGetFromArray(table->splitters, i-1);
|
splitter = WMGetFromArray(table->splitters, i-1);
|
||||||
W_MoveView(splitter, x + rect.pos.x - 1, 0);
|
W_MoveView(splitter, x - rect.pos.x - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += W_VIEW_WIDTH(WMWidgetView(column->titleW)) + 1;
|
x += W_VIEW_WIDTH(WMWidgetView(column->titleW)) + 1;
|
||||||
@@ -268,6 +278,7 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
|||||||
WMMoveWidget(table->header, 22, 2);
|
WMMoveWidget(table->header, 22, 2);
|
||||||
WMMapWidget(table->header);
|
WMMapWidget(table->header);
|
||||||
WMSetFrameRelief(table->header, WRFlat);
|
WMSetFrameRelief(table->header, WRFlat);
|
||||||
|
|
||||||
table->corner = WMCreateLabel(table);
|
table->corner = WMCreateLabel(table);
|
||||||
WMResizeWidget(table->corner, 20, table->headerHeight);
|
WMResizeWidget(table->corner, 20, table->headerHeight);
|
||||||
WMMoveWidget(table->corner, 2, 2);
|
WMMoveWidget(table->corner, 2, 2);
|
||||||
@@ -287,7 +298,8 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
|||||||
|
|
||||||
table->tableView->flags.dontCompressExpose = 1;
|
table->tableView->flags.dontCompressExpose = 1;
|
||||||
|
|
||||||
table->gridColor = WMDarkGrayColor(scr);
|
table->gridColor = WMCreateNamedColor(scr, "#cccccc", False);
|
||||||
|
/* table->gridColor = WMGrayColor(scr);*/
|
||||||
|
|
||||||
{
|
{
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
@@ -300,10 +312,13 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
table->editingRow = -1;
|
table->editingRow = -1;
|
||||||
|
table->clickedRow = -1;
|
||||||
|
|
||||||
table->drawsGrid = 1;
|
table->drawsGrid = 1;
|
||||||
table->rowHeight = 16;
|
table->rowHeight = 16;
|
||||||
|
|
||||||
|
WMSetScrollViewLineScroll(table->scrollView, table->rowHeight);
|
||||||
|
|
||||||
table->tableWidth = 1;
|
table->tableWidth = 1;
|
||||||
|
|
||||||
table->columns = WMCreateArray(4);
|
table->columns = WMCreateArray(4);
|
||||||
@@ -319,7 +334,8 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
|||||||
WMCreateEventHandler(table->view, ExposureMask|StructureNotifyMask,
|
WMCreateEventHandler(table->view, ExposureMask|StructureNotifyMask,
|
||||||
handleEvents, table);
|
handleEvents, table);
|
||||||
|
|
||||||
WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask,
|
WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask|
|
||||||
|
ButtonReleaseMask|ButtonMotionMask,
|
||||||
handleTableEvents, table);
|
handleTableEvents, table);
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
@@ -379,29 +395,7 @@ void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column)
|
|||||||
WMAddToArray(table->splitters, splitter);
|
WMAddToArray(table->splitters, splitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
count = WMGetArrayItemCount(table->columns);
|
rearrangeHeader(table);
|
||||||
for (i = 0, width = 0; i < count; i++) {
|
|
||||||
WMTableColumn *column = WMGetFromArray(table->columns, i);
|
|
||||||
|
|
||||||
WMMoveWidget(column->titleW, width, 0);
|
|
||||||
WMResizeWidget(column->titleW, column->width-1, table->headerHeight);
|
|
||||||
|
|
||||||
if (i > 0) {
|
|
||||||
WMView *splitter = WMGetFromArray(table->splitters, i-1);
|
|
||||||
|
|
||||||
W_MoveView(splitter, width-1, 0);
|
|
||||||
}
|
|
||||||
width += column->width;
|
|
||||||
}
|
|
||||||
|
|
||||||
wassertr(table->delegate && table->delegate->numberOfRows);
|
|
||||||
|
|
||||||
table->rows = table->delegate->numberOfRows(table->delegate, table);
|
|
||||||
|
|
||||||
W_ResizeView(table->tableView, width+1,
|
|
||||||
table->rows * table->rowHeight + 1);
|
|
||||||
|
|
||||||
table->tableWidth = width + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -419,6 +413,26 @@ void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WMSetTableViewAction(WMTableView *table, WMAction *action, void *clientData)
|
||||||
|
{
|
||||||
|
table->action = action;
|
||||||
|
|
||||||
|
table->clientData = clientData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *WMGetTableViewClickedColumn(WMTableView *table)
|
||||||
|
{
|
||||||
|
return table->clickedColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int WMGetTableViewClickedRow(WMTableView *table)
|
||||||
|
{
|
||||||
|
return table->clickedRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WMView *WMGetTableViewDocumentView(WMTableView *table)
|
WMView *WMGetTableViewDocumentView(WMTableView *table)
|
||||||
{
|
{
|
||||||
return table->tableView;
|
return table->tableView;
|
||||||
@@ -486,7 +500,42 @@ void WMSetTableViewGridColor(WMTableView *table, WMColor *color)
|
|||||||
{
|
{
|
||||||
WMReleaseColor(table->gridColor);
|
WMReleaseColor(table->gridColor);
|
||||||
table->gridColor = WMRetainColor(color);
|
table->gridColor = WMRetainColor(color);
|
||||||
XSetForeground(WMScreenDisplay(WMWidgetScreen(table)), table->gridGC, WMColorPixel(color));
|
XSetForeground(WMScreenDisplay(WMWidgetScreen(table)), table->gridGC,
|
||||||
|
WMColorPixel(color));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WMSetTableViewRowHeight(WMTableView *table, int height)
|
||||||
|
{
|
||||||
|
table->rowHeight = height;
|
||||||
|
|
||||||
|
WMRedisplayWidget(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WMScrollTableViewRowToVisible(WMTableView *table, int row)
|
||||||
|
{
|
||||||
|
WMScroller *scroller;
|
||||||
|
WMRange range;
|
||||||
|
WMRect rect;
|
||||||
|
int newY, tmp;
|
||||||
|
|
||||||
|
rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
range = rowsInRect(table, rect);
|
||||||
|
|
||||||
|
scroller = WMGetScrollViewVerticalScroller(table->scrollView);
|
||||||
|
|
||||||
|
if (row < range.position) {
|
||||||
|
newY = row * table->rowHeight - rect.size.height / 2;
|
||||||
|
} else if (row >= range.position + range.count) {
|
||||||
|
newY = row * table->rowHeight - rect.size.height / 2;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tmp = table->rows*table->rowHeight - rect.size.height;
|
||||||
|
newY = WMAX(0, WMIN(newY, tmp));
|
||||||
|
WMScrollViewScrollPoint(table->scrollView, rect.pos.x, newY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -580,9 +629,12 @@ static WMRange rowsInRect(WMTableView *table, WMRect rect)
|
|||||||
{
|
{
|
||||||
WMRange range;
|
WMRange range;
|
||||||
int rh = table->rowHeight;
|
int rh = table->rowHeight;
|
||||||
|
int dif;
|
||||||
|
|
||||||
range.position = WMAX(0, rect.pos.y / rh - 1);
|
dif = rect.pos.y % rh;
|
||||||
range.count = WMAX(1, WMIN(rect.size.height / rh + 3, table->rows));
|
|
||||||
|
range.position = WMAX(0, (rect.pos.y - dif) / rh);
|
||||||
|
range.count = WMAX(1, WMIN((rect.size.height + dif) / rh, table->rows));
|
||||||
|
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
@@ -630,30 +682,14 @@ static void setRowSelected(WMTableView *table, unsigned row, Bool flag)
|
|||||||
int repaint = 0;
|
int repaint = 0;
|
||||||
|
|
||||||
|
|
||||||
if (WMGetArrayItemCount(table->selectedRows) > 0
|
|
||||||
&& !table->canSelectMultiRows) {
|
|
||||||
int r = (int)WMGetFromArray(table->selectedRows, 0);
|
|
||||||
|
|
||||||
WMDeleteFromArray(table->selectedRows, 0);
|
|
||||||
|
|
||||||
drawFullRow(table, r);
|
|
||||||
|
|
||||||
WMPostNotificationName(WMTableViewRowWasUnselectedNotification,
|
|
||||||
table, (void*)r);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) {
|
if (WMFindInArray(table->selectedRows, NULL, (void*)row) != WANotFound) {
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
WMRemoveFromArray(table->selectedRows, (void*)row);
|
WMRemoveFromArray(table->selectedRows, (void*)row);
|
||||||
WMPostNotificationName(WMTableViewRowWasUnselectedNotification,
|
|
||||||
table, (void*)row);
|
|
||||||
repaint = 1;
|
repaint = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
WMAddToArray(table->selectedRows, (void*)row);
|
WMAddToArray(table->selectedRows, (void*)row);
|
||||||
WMPostNotificationName(WMTableViewRowWasSelectedNotification,
|
|
||||||
table, (void*)row);
|
|
||||||
repaint = 1;
|
repaint = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -690,7 +726,7 @@ static void repaintTable(WMTableView *table, int x, int y,
|
|||||||
|
|
||||||
rows = rowsInRect(table, rect);
|
rows = rowsInRect(table, rect);
|
||||||
for (i = rows.position;
|
for (i = rows.position;
|
||||||
i < WMIN(rows.position+rows.count, table->rows);
|
i < WMIN(rows.position+rows.count + 1, table->rows);
|
||||||
i++) {
|
i++) {
|
||||||
drawRow(table, i, rect);
|
drawRow(table, i, rect);
|
||||||
}
|
}
|
||||||
@@ -706,8 +742,7 @@ static void stopRowEdit(WMTableView *table, int row)
|
|||||||
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
||||||
column = WMGetFromArray(table->columns, i);
|
column = WMGetFromArray(table->columns, i);
|
||||||
|
|
||||||
wassertr(column->delegate && column->delegate->endCellEdit);
|
if (column->delegate && column->delegate->endCellEdit)
|
||||||
|
|
||||||
(*column->delegate->endCellEdit)(column->delegate, column, row);
|
(*column->delegate->endCellEdit)(column->delegate, column, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -727,20 +762,78 @@ void WMEditTableViewRow(WMTableView *table, int row)
|
|||||||
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
||||||
column = WMGetFromArray(table->columns, i);
|
column = WMGetFromArray(table->columns, i);
|
||||||
|
|
||||||
wassertr(column->delegate && column->delegate->beginCellEdit);
|
if (column->delegate && column->delegate->beginCellEdit)
|
||||||
|
|
||||||
(*column->delegate->beginCellEdit)(column->delegate, column, row);
|
(*column->delegate->beginCellEdit)(column->delegate, column, row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WMSelectTableViewRow(WMTableView *table, int row)
|
||||||
|
{
|
||||||
|
if (table->clickedRow >= 0)
|
||||||
|
setRowSelected(table, table->clickedRow, False);
|
||||||
|
setRowSelected(table, row, True);
|
||||||
|
table->clickedRow = row;
|
||||||
|
|
||||||
|
if (table->action)
|
||||||
|
(*table->action)(table, table->clientData);
|
||||||
|
WMPostNotificationName(WMTableViewSelectionDidChangeNotification,
|
||||||
|
table, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WMReloadTableView(WMTableView *table)
|
||||||
|
{
|
||||||
|
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
|
||||||
|
repaintTable(table, 0, 0,
|
||||||
|
W_VIEW_WIDTH(table->tableView), rect.size.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WMNoteTableViewNumberOfRowsChanged(WMTableView *table)
|
||||||
|
{
|
||||||
|
WMReloadTableView(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void handleTableEvents(XEvent *event, void *data)
|
static void handleTableEvents(XEvent *event, void *data)
|
||||||
{
|
{
|
||||||
WMTableView *table = (WMTableView*)data;
|
WMTableView *table = (WMTableView*)data;
|
||||||
|
int row;
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
setRowSelected(table, event->xbutton.y/table->rowHeight, True);
|
if (event->xbutton.button == Button1) {
|
||||||
|
row = event->xbutton.y/table->rowHeight;
|
||||||
|
if (row != table->clickedRow) {
|
||||||
|
setRowSelected(table, table->clickedRow, False);
|
||||||
|
setRowSelected(table, row, True);
|
||||||
|
table->clickedRow = row;
|
||||||
|
table->dragging = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MotionNotify:
|
||||||
|
if (table->dragging && event->xmotion.y >= 0) {
|
||||||
|
row = event->xmotion.y/table->rowHeight;
|
||||||
|
if (table->clickedRow != row && row >= 0) {
|
||||||
|
setRowSelected(table, table->clickedRow, False);
|
||||||
|
setRowSelected(table, row, True);
|
||||||
|
table->clickedRow = row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ButtonRelease:
|
||||||
|
if (event->xbutton.button == Button1) {
|
||||||
|
if (table->action)
|
||||||
|
(*table->action)(table, table->clientData);
|
||||||
|
WMPostNotificationName(WMTableViewSelectionDidChangeNotification,
|
||||||
|
table, NULL);
|
||||||
|
table->dragging = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Expose:
|
case Expose:
|
||||||
@@ -761,6 +854,13 @@ static void handleEvents(XEvent *event, void *data)
|
|||||||
W_DrawRelief(scr, W_VIEW_DRAWABLE(table->view), 0, 0,
|
W_DrawRelief(scr, W_VIEW_DRAWABLE(table->view), 0, 0,
|
||||||
W_VIEW_WIDTH(table->view), W_VIEW_HEIGHT(table->view),
|
W_VIEW_WIDTH(table->view), W_VIEW_HEIGHT(table->view),
|
||||||
WRSunken);
|
WRSunken);
|
||||||
|
|
||||||
|
if (event->xexpose.serial == 0) {
|
||||||
|
WMRect rect = WMGetScrollViewVisibleRect(table->scrollView);
|
||||||
|
|
||||||
|
repaintTable(table, rect.pos.x, rect.pos.y,
|
||||||
|
rect.size.width, rect.size.height);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,3 +889,34 @@ static void handleResize(W_ViewDelegate *self, WMView *view)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void rearrangeHeader(WMTableView *table)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
int count;
|
||||||
|
int i;
|
||||||
|
width = 0;
|
||||||
|
|
||||||
|
count = WMGetArrayItemCount(table->columns);
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
WMTableColumn *column = WMGetFromArray(table->columns, i);
|
||||||
|
|
||||||
|
WMMoveWidget(column->titleW, width, 0);
|
||||||
|
WMResizeWidget(column->titleW, column->width-1, table->headerHeight);
|
||||||
|
|
||||||
|
if (i > 0) {
|
||||||
|
WMView *splitter = WMGetFromArray(table->splitters, i-1);
|
||||||
|
|
||||||
|
W_MoveView(splitter, width-1, 0);
|
||||||
|
}
|
||||||
|
width += column->width;
|
||||||
|
}
|
||||||
|
|
||||||
|
wassertr(table->delegate && table->delegate->numberOfRows);
|
||||||
|
|
||||||
|
table->rows = table->delegate->numberOfRows(table->delegate, table);
|
||||||
|
|
||||||
|
W_ResizeView(table->tableView, width+1,
|
||||||
|
table->rows * table->rowHeight + 1);
|
||||||
|
|
||||||
|
table->tableWidth = width + 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ typedef struct W_TableColumn WMTableColumn;
|
|||||||
typedef struct W_TableView WMTableView;
|
typedef struct W_TableView WMTableView;
|
||||||
|
|
||||||
|
|
||||||
extern const char *WMTableViewRowWasSelectedNotification;
|
extern const char *WMTableViewSelectionDidChangeNotification;
|
||||||
extern const char *WMTableViewRowWasUnselectedNotification;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct WMTableColumnDelegate {
|
typedef struct WMTableColumnDelegate {
|
||||||
@@ -50,6 +49,7 @@ void WMSetTableColumnWidth(WMTableColumn *column, unsigned width);
|
|||||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||||
WMTableColumnDelegate *delegate);
|
WMTableColumnDelegate *delegate);
|
||||||
|
|
||||||
|
|
||||||
WMTableView *WMGetTableColumnTableView(WMTableColumn *column);
|
WMTableView *WMGetTableColumnTableView(WMTableColumn *column);
|
||||||
|
|
||||||
void WMSetTableColumnId(WMTableColumn *column, void *id);
|
void WMSetTableColumnId(WMTableColumn *column, void *id);
|
||||||
@@ -70,10 +70,19 @@ void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column);
|
|||||||
|
|
||||||
void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate);
|
void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate);
|
||||||
|
|
||||||
|
void WMSetTableViewAction(WMTableView *table, WMAction *action,
|
||||||
|
void *clientData);
|
||||||
|
|
||||||
|
void *WMGetTableViewClickedColumn(WMTableView *table);
|
||||||
|
|
||||||
|
int WMGetTableViewClickedRow(WMTableView *table);
|
||||||
|
|
||||||
WMView *WMGetTableViewDocumentView(WMTableView *table);
|
WMView *WMGetTableViewDocumentView(WMTableView *table);
|
||||||
|
|
||||||
void WMEditTableViewRow(WMTableView *table, int row);
|
void WMEditTableViewRow(WMTableView *table, int row);
|
||||||
|
|
||||||
|
void WMSelectTableViewRow(WMTableView *table, int row);
|
||||||
|
|
||||||
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||||
int row);
|
int row);
|
||||||
|
|
||||||
@@ -87,6 +96,13 @@ void WMSetTableViewBackgroundColor(WMTableView *table, WMColor *color);
|
|||||||
|
|
||||||
void WMSetTableViewGridColor(WMTableView *table, WMColor *color);
|
void WMSetTableViewGridColor(WMTableView *table, WMColor *color);
|
||||||
|
|
||||||
|
void WMSetTableViewRowHeight(WMTableView *table, int height);
|
||||||
|
|
||||||
|
void WMReloadTableView(WMTableView *table);
|
||||||
|
|
||||||
|
void WMNoteTableViewNumberOfRowsChanged(WMTableView *table);
|
||||||
|
|
||||||
|
void WMScrollTableViewRowToVisible(WMTableView *table, int row);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ testText(WMScreen *scr)
|
|||||||
{
|
{
|
||||||
WMWindow *win;
|
WMWindow *win;
|
||||||
WMText *text;
|
WMText *text;
|
||||||
FILE *file = fopen("../README", "r");
|
FILE *file = fopen("wm.html", "r");
|
||||||
|
|
||||||
windowCount++;
|
windowCount++;
|
||||||
|
|
||||||
@@ -1231,7 +1231,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
/* Initialize the application */
|
/* Initialize the application */
|
||||||
WMInitializeApplication("Test", &argc, argv);
|
WMInitializeApplication("Test@eqweq_ewq$eqw", &argc, argv);
|
||||||
|
|
||||||
testUD();
|
testUD();
|
||||||
|
|
||||||
@@ -1273,10 +1273,11 @@ main(int argc, char **argv)
|
|||||||
* Put the testSomething() function you want to test here.
|
* Put the testSomething() function you want to test here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
testBox(scr);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
testTabView(scr);
|
testTabView(scr);
|
||||||
|
#if 0
|
||||||
|
testBox(scr);
|
||||||
|
testText(scr);
|
||||||
testList(scr);
|
testList(scr);
|
||||||
|
|
||||||
testProgressIndicator(scr);
|
testProgressIndicator(scr);
|
||||||
@@ -1284,7 +1285,6 @@ main(int argc, char **argv)
|
|||||||
testColorWell(scr);
|
testColorWell(scr);
|
||||||
|
|
||||||
testTextField(scr);
|
testTextField(scr);
|
||||||
testText(scr);
|
|
||||||
|
|
||||||
testDragAndDrop(scr);
|
testDragAndDrop(scr);
|
||||||
testDragAndDrop(scr);
|
testDragAndDrop(scr);
|
||||||
|
|||||||
@@ -1611,6 +1611,8 @@ void WMDestroyTextBlock(WMText *tPtr, void *vtb);
|
|||||||
|
|
||||||
WMTabView *WMCreateTabView(WMWidget *parent);
|
WMTabView *WMCreateTabView(WMWidget *parent);
|
||||||
|
|
||||||
|
void WMSetTabViewType(WMTabView *tPtr, WMTabViewType type);
|
||||||
|
|
||||||
void WMSetTabViewFont(WMTabView *tPtr, WMFont *font);
|
void WMSetTabViewFont(WMTabView *tPtr, WMFont *font);
|
||||||
|
|
||||||
void WMAddItemInTabView(WMTabView *tPtr, WMTabViewItem *item);
|
void WMAddItemInTabView(WMTabView *tPtr, WMTabViewItem *item);
|
||||||
@@ -1665,6 +1667,9 @@ void WMSetBoxBorderWidth(WMBox *box, unsigned width);
|
|||||||
void WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
void WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||||
int minSize, int maxSize, int space);
|
int minSize, int maxSize, int space);
|
||||||
|
|
||||||
|
void WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||||
|
int minSize, int maxSize, int space);
|
||||||
|
|
||||||
void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
||||||
|
|
||||||
/* ....................................................................... */
|
/* ....................................................................... */
|
||||||
|
|||||||
@@ -294,18 +294,18 @@ void WMFreeHashTable(WMHashTable *table);
|
|||||||
|
|
||||||
void WMResetHashTable(WMHashTable *table);
|
void WMResetHashTable(WMHashTable *table);
|
||||||
|
|
||||||
void* WMHashGet(WMHashTable *table, const void *key);
|
const void* WMHashGet(WMHashTable *table, const void *key);
|
||||||
|
|
||||||
/* put data in table, replacing already existing data and returning
|
/* put data in table, replacing already existing data and returning
|
||||||
* the old value */
|
* the old value */
|
||||||
void* WMHashInsert(WMHashTable *table, void *key, void *data);
|
const void* WMHashInsert(WMHashTable *table, const void *key, const void *data);
|
||||||
|
|
||||||
void WMHashRemove(WMHashTable *table, const void *key);
|
void WMHashRemove(WMHashTable *table, const void *key);
|
||||||
|
|
||||||
/* warning: do not manipulate the table while using these functions */
|
/* warning: do not manipulate the table while using these functions */
|
||||||
WMHashEnumerator WMEnumerateHashTable(WMHashTable *table);
|
WMHashEnumerator WMEnumerateHashTable(WMHashTable *table);
|
||||||
|
|
||||||
void* WMNextHashEnumeratorItem(WMHashEnumerator *enumerator);
|
const void* WMNextHashEnumeratorItem(WMHashEnumerator *enumerator);
|
||||||
|
|
||||||
unsigned WMCountHashTable(WMHashTable *table);
|
unsigned WMCountHashTable(WMHashTable *table);
|
||||||
|
|
||||||
@@ -571,7 +571,7 @@ unsigned WMGetDataFormat(WMData *aData);
|
|||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
WMNotification* WMCreateNotification(char *name, void *object, void *clientData);
|
WMNotification* WMCreateNotification(const char *name, void *object, void *clientData);
|
||||||
|
|
||||||
void WMReleaseNotification(WMNotification *notification);
|
void WMReleaseNotification(WMNotification *notification);
|
||||||
|
|
||||||
@@ -581,20 +581,20 @@ void* WMGetNotificationClientData(WMNotification *notification);
|
|||||||
|
|
||||||
void* WMGetNotificationObject(WMNotification *notification);
|
void* WMGetNotificationObject(WMNotification *notification);
|
||||||
|
|
||||||
char* WMGetNotificationName(WMNotification *notification);
|
const char* WMGetNotificationName(WMNotification *notification);
|
||||||
|
|
||||||
|
|
||||||
void WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
void WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||||
void *observer, char *name, void *object);
|
void *observer, const char *name, void *object);
|
||||||
|
|
||||||
void WMPostNotification(WMNotification *notification);
|
void WMPostNotification(WMNotification *notification);
|
||||||
|
|
||||||
void WMRemoveNotificationObserver(void *observer);
|
void WMRemoveNotificationObserver(void *observer);
|
||||||
|
|
||||||
void WMRemoveNotificationObserverWithName(void *observer, char *name,
|
void WMRemoveNotificationObserverWithName(void *observer, const char *name,
|
||||||
void *object);
|
void *object);
|
||||||
|
|
||||||
void WMPostNotificationName(char *name, void *object, void *clientData);
|
void WMPostNotificationName(const char *name, void *object, void *clientData);
|
||||||
|
|
||||||
WMNotificationQueue* WMGetDefaultNotificationQueue(void);
|
WMNotificationQueue* WMGetDefaultNotificationQueue(void);
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct HashItem {
|
typedef struct HashItem {
|
||||||
void *key;
|
const void *key;
|
||||||
void *data;
|
const void *data;
|
||||||
|
|
||||||
struct HashItem *next; /* collided item list */
|
struct HashItem *next; /* collided item list */
|
||||||
} HashItem;
|
} HashItem;
|
||||||
@@ -186,7 +186,7 @@ WMFreeHashTable(WMHashTable *table)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void*
|
const void*
|
||||||
WMHashGet(WMHashTable *table, const void *key)
|
WMHashGet(WMHashTable *table, const void *key)
|
||||||
{
|
{
|
||||||
unsigned h;
|
unsigned h;
|
||||||
@@ -218,8 +218,8 @@ WMHashGet(WMHashTable *table, const void *key)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void*
|
const void*
|
||||||
WMHashInsert(WMHashTable *table, void *key, void *data)
|
WMHashInsert(WMHashTable *table, const void *key, const void *data)
|
||||||
{
|
{
|
||||||
unsigned h;
|
unsigned h;
|
||||||
HashItem *item;
|
HashItem *item;
|
||||||
@@ -247,7 +247,7 @@ WMHashInsert(WMHashTable *table, void *key, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (replacing) {
|
if (replacing) {
|
||||||
void *old;
|
const void *old;
|
||||||
|
|
||||||
old = item->data;
|
old = item->data;
|
||||||
item->data = data;
|
item->data = data;
|
||||||
@@ -334,10 +334,10 @@ WMEnumerateHashTable(WMHashTable *table)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void*
|
const void*
|
||||||
WMNextHashEnumeratorItem(WMHashEnumerator *enumerator)
|
WMNextHashEnumeratorItem(WMHashEnumerator *enumerator)
|
||||||
{
|
{
|
||||||
void *data = NULL;
|
const void *data = NULL;
|
||||||
|
|
||||||
/* this assumes the table doesn't change between
|
/* this assumes the table doesn't change between
|
||||||
* WMEnumerateHashTable() and WMNextHashEnumeratorItem() calls */
|
* WMEnumerateHashTable() and WMNextHashEnumeratorItem() calls */
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct W_Notification {
|
typedef struct W_Notification {
|
||||||
char *name;
|
const char *name;
|
||||||
void *object;
|
void *object;
|
||||||
void *clientData;
|
void *clientData;
|
||||||
int refCount;
|
int refCount;
|
||||||
@@ -18,7 +18,7 @@ typedef struct W_Notification {
|
|||||||
extern void W_FlushASAPNotificationQueue();
|
extern void W_FlushASAPNotificationQueue();
|
||||||
|
|
||||||
|
|
||||||
char*
|
const char*
|
||||||
WMGetNotificationName(WMNotification *notification)
|
WMGetNotificationName(WMNotification *notification)
|
||||||
{
|
{
|
||||||
return notification->name;
|
return notification->name;
|
||||||
@@ -40,7 +40,7 @@ WMGetNotificationClientData(WMNotification *notification)
|
|||||||
|
|
||||||
|
|
||||||
WMNotification*
|
WMNotification*
|
||||||
WMCreateNotification(char *name, void *object, void *clientData)
|
WMCreateNotification(const char *name, void *object, void *clientData)
|
||||||
{
|
{
|
||||||
Notification *nPtr;
|
Notification *nPtr;
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ typedef struct NotificationObserver {
|
|||||||
WMNotificationObserverAction *observerAction;
|
WMNotificationObserverAction *observerAction;
|
||||||
void *observer;
|
void *observer;
|
||||||
|
|
||||||
char *name;
|
const char *name;
|
||||||
void *object;
|
void *object;
|
||||||
|
|
||||||
struct NotificationObserver *prev; /* for tables */
|
struct NotificationObserver *prev; /* for tables */
|
||||||
@@ -119,7 +119,7 @@ W_InitNotificationCenter(void)
|
|||||||
|
|
||||||
void
|
void
|
||||||
WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||||
void *observer, char *name, void *object)
|
void *observer, const char *name, void *object)
|
||||||
{
|
{
|
||||||
NotificationObserver *oRec, *rec;
|
NotificationObserver *oRec, *rec;
|
||||||
|
|
||||||
@@ -133,7 +133,8 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
|||||||
|
|
||||||
|
|
||||||
/* put this action in the list of actions for this observer */
|
/* put this action in the list of actions for this observer */
|
||||||
rec = WMHashInsert(notificationCenter->observerTable, observer, oRec);
|
rec = (NotificationObserver*)WMHashInsert(notificationCenter->observerTable,
|
||||||
|
observer, oRec);
|
||||||
|
|
||||||
if (rec) {
|
if (rec) {
|
||||||
/* if this is not the first action for the observer */
|
/* if this is not the first action for the observer */
|
||||||
@@ -151,14 +152,16 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
|||||||
notificationCenter->nilList = oRec;
|
notificationCenter->nilList = oRec;
|
||||||
} else if (!name) {
|
} else if (!name) {
|
||||||
/* any message coming from object */
|
/* any message coming from object */
|
||||||
rec = WMHashInsert(notificationCenter->objectTable, object, oRec);
|
rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable,
|
||||||
|
object, oRec);
|
||||||
oRec->next = rec;
|
oRec->next = rec;
|
||||||
if (rec) {
|
if (rec) {
|
||||||
rec->prev = oRec;
|
rec->prev = oRec;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* name && (object || !object) */
|
/* name && (object || !object) */
|
||||||
rec = WMHashInsert(notificationCenter->nameTable, name, oRec);
|
rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable,
|
||||||
|
name, oRec);
|
||||||
oRec->next = rec;
|
oRec->next = rec;
|
||||||
if (rec) {
|
if (rec) {
|
||||||
rec->prev = oRec;
|
rec->prev = oRec;
|
||||||
@@ -175,7 +178,8 @@ WMPostNotification(WMNotification *notification)
|
|||||||
WMRetainNotification(notification);
|
WMRetainNotification(notification);
|
||||||
|
|
||||||
/* tell the observers that want to know about a particular message */
|
/* tell the observers that want to know about a particular message */
|
||||||
orec = WMHashGet(notificationCenter->nameTable, notification->name);
|
orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||||
|
notification->name);
|
||||||
|
|
||||||
while (orec) {
|
while (orec) {
|
||||||
tmp = orec->next;
|
tmp = orec->next;
|
||||||
@@ -192,7 +196,8 @@ WMPostNotification(WMNotification *notification)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tell the observers that want to know about an object */
|
/* tell the observers that want to know about an object */
|
||||||
orec = WMHashGet(notificationCenter->objectTable, notification->object);
|
orec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
|
||||||
|
notification->object);
|
||||||
|
|
||||||
while (orec) {
|
while (orec) {
|
||||||
tmp = orec->next;
|
tmp = orec->next;
|
||||||
@@ -226,7 +231,8 @@ WMRemoveNotificationObserver(void *observer)
|
|||||||
NotificationObserver *orec, *tmp, *rec;
|
NotificationObserver *orec, *tmp, *rec;
|
||||||
|
|
||||||
/* get the list of actions the observer is doing */
|
/* get the list of actions the observer is doing */
|
||||||
orec = WMHashGet(notificationCenter->observerTable, observer);
|
orec = (NotificationObserver*)WMHashGet(notificationCenter->observerTable,
|
||||||
|
observer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FOREACH orec IN actionlist for observer
|
* FOREACH orec IN actionlist for observer
|
||||||
@@ -244,7 +250,8 @@ WMRemoveNotificationObserver(void *observer)
|
|||||||
notificationCenter->nilList = orec->next;
|
notificationCenter->nilList = orec->next;
|
||||||
} else if (!orec->name) {
|
} else if (!orec->name) {
|
||||||
/* any message coming from object */
|
/* any message coming from object */
|
||||||
rec = WMHashGet(notificationCenter->objectTable, orec->object);
|
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
|
||||||
|
orec->object);
|
||||||
if (rec==orec) {
|
if (rec==orec) {
|
||||||
/* replace table entry */
|
/* replace table entry */
|
||||||
if (orec->next) {
|
if (orec->next) {
|
||||||
@@ -256,7 +263,8 @@ WMRemoveNotificationObserver(void *observer)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* name && (object || !object) */
|
/* name && (object || !object) */
|
||||||
rec = WMHashGet(notificationCenter->nameTable, orec->name);
|
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||||
|
orec->name);
|
||||||
if (rec==orec) {
|
if (rec==orec) {
|
||||||
/* replace table entry */
|
/* replace table entry */
|
||||||
if (orec->next) {
|
if (orec->next) {
|
||||||
@@ -282,13 +290,13 @@ WMRemoveNotificationObserver(void *observer)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
WMRemoveNotificationObserverWithName(void *observer, const char *name, void *object)
|
||||||
{
|
{
|
||||||
NotificationObserver *orec, *tmp, *rec;
|
NotificationObserver *orec, *tmp, *rec;
|
||||||
NotificationObserver *newList = NULL;
|
NotificationObserver *newList = NULL;
|
||||||
|
|
||||||
/* get the list of actions the observer is doing */
|
/* get the list of actions the observer is doing */
|
||||||
orec = WMHashGet(notificationCenter->observerTable, observer);
|
orec = (NotificationObserver*)WMHashGet(notificationCenter->observerTable, observer);
|
||||||
|
|
||||||
WMHashRemove(notificationCenter->observerTable, observer);
|
WMHashRemove(notificationCenter->observerTable, observer);
|
||||||
|
|
||||||
@@ -301,7 +309,7 @@ WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
|||||||
if (notificationCenter->nilList == orec)
|
if (notificationCenter->nilList == orec)
|
||||||
notificationCenter->nilList = orec->next;
|
notificationCenter->nilList = orec->next;
|
||||||
} else if (!name) {
|
} else if (!name) {
|
||||||
rec = WMHashGet(notificationCenter->objectTable, orec->object);
|
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object);
|
||||||
if (rec==orec) {
|
if (rec==orec) {
|
||||||
assert(rec->prev==NULL);
|
assert(rec->prev==NULL);
|
||||||
/* replace table entry */
|
/* replace table entry */
|
||||||
@@ -314,7 +322,8 @@ WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rec = WMHashGet(notificationCenter->nameTable, orec->name);
|
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||||
|
orec->name);
|
||||||
if (rec==orec) {
|
if (rec==orec) {
|
||||||
assert(rec->prev==NULL);
|
assert(rec->prev==NULL);
|
||||||
/* replace table entry */
|
/* replace table entry */
|
||||||
@@ -359,7 +368,7 @@ WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WMPostNotificationName(char *name, void *object, void *clientData)
|
WMPostNotificationName(const char *name, void *object, void *clientData)
|
||||||
{
|
{
|
||||||
WMNotification *notification;
|
WMNotification *notification;
|
||||||
|
|
||||||
|
|||||||
44
WINGs/wbox.c
44
WINGs/wbox.c
@@ -10,6 +10,7 @@ typedef struct {
|
|||||||
int space;
|
int space;
|
||||||
unsigned expand:1;
|
unsigned expand:1;
|
||||||
unsigned fill:1;
|
unsigned fill:1;
|
||||||
|
unsigned end:1;
|
||||||
} SubviewItem;
|
} SubviewItem;
|
||||||
|
|
||||||
|
|
||||||
@@ -82,16 +83,22 @@ rearrange(WMBox *box)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
int xe, ye;
|
||||||
int w = 1, h = 1;
|
int w = 1, h = 1;
|
||||||
int total;
|
int total;
|
||||||
int expands = 0;
|
int expands = 0;
|
||||||
|
|
||||||
x = box->borderWidth;
|
x = box->borderWidth;
|
||||||
y = box->borderWidth;
|
y = box->borderWidth;
|
||||||
|
|
||||||
if (box->horizontal) {
|
if (box->horizontal) {
|
||||||
|
ye = box->borderWidth;
|
||||||
|
xe = WMWidgetWidth(box) - box->borderWidth;
|
||||||
h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||||
total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||||
} else {
|
} else {
|
||||||
|
xe = box->borderWidth;
|
||||||
|
ye = WMWidgetHeight(box) - box->borderWidth;
|
||||||
w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||||
total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||||
}
|
}
|
||||||
@@ -118,13 +125,24 @@ rearrange(WMBox *box)
|
|||||||
if (box->subviews[i].expand)
|
if (box->subviews[i].expand)
|
||||||
h += total/expands;
|
h += total/expands;
|
||||||
}
|
}
|
||||||
|
if (!box->subviews[i].end) {
|
||||||
W_MoveView(box->subviews[i].view, x, y);
|
W_MoveView(box->subviews[i].view, x, y);
|
||||||
|
}
|
||||||
W_ResizeView(box->subviews[i].view, w, h);
|
W_ResizeView(box->subviews[i].view, w, h);
|
||||||
if (box->horizontal) {
|
if (box->horizontal) {
|
||||||
|
if (box->subviews[i].end)
|
||||||
|
xe -= w + box->subviews[i].space;
|
||||||
|
else
|
||||||
x += w + box->subviews[i].space;
|
x += w + box->subviews[i].space;
|
||||||
} else {
|
} else {
|
||||||
|
if (box->subviews[i].end)
|
||||||
|
ye -= h + box->subviews[i].space;
|
||||||
|
else
|
||||||
y += h + box->subviews[i].space;
|
y += h + box->subviews[i].space;
|
||||||
}
|
}
|
||||||
|
if (box->subviews[i].end) {
|
||||||
|
W_MoveView(box->subviews[i].view, xe, ye);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +174,32 @@ WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
|||||||
bPtr->subviews[i].expand = expand;
|
bPtr->subviews[i].expand = expand;
|
||||||
bPtr->subviews[i].fill = fill;
|
bPtr->subviews[i].fill = fill;
|
||||||
bPtr->subviews[i].space = space;
|
bPtr->subviews[i].space = space;
|
||||||
|
bPtr->subviews[i].end = 0;
|
||||||
|
|
||||||
|
rearrange(bPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||||
|
int minSize, int maxSize, int space)
|
||||||
|
{
|
||||||
|
int i = bPtr->subviewCount;
|
||||||
|
|
||||||
|
bPtr->subviewCount++;
|
||||||
|
if (!bPtr->subviews)
|
||||||
|
bPtr->subviews = wmalloc(sizeof(SubviewItem));
|
||||||
|
else
|
||||||
|
bPtr->subviews = wrealloc(bPtr->subviews,
|
||||||
|
bPtr->subviewCount*sizeof(SubviewItem));
|
||||||
|
bPtr->subviews[i].view = view;
|
||||||
|
bPtr->subviews[i].minSize = minSize;
|
||||||
|
bPtr->subviews[i].maxSize = maxSize;
|
||||||
|
bPtr->subviews[i].expand = expand;
|
||||||
|
bPtr->subviews[i].fill = fill;
|
||||||
|
bPtr->subviews[i].space = space;
|
||||||
|
bPtr->subviews[i].end = 1;
|
||||||
|
|
||||||
rearrange(bPtr);
|
rearrange(bPtr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,11 +412,11 @@ WMSetButtonSelected(WMButton *bPtr, int isSelected)
|
|||||||
{
|
{
|
||||||
bPtr->flags.selected = isSelected;
|
bPtr->flags.selected = isSelected;
|
||||||
|
|
||||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
|
||||||
|
|
||||||
if (bPtr->view->flags.realized) {
|
if (bPtr->view->flags.realized) {
|
||||||
paintButton(bPtr);
|
paintButton(bPtr);
|
||||||
}
|
}
|
||||||
|
if (bPtr->groupIndex > 0)
|
||||||
|
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -486,6 +486,8 @@ WMPerformButtonClick(WMButton *bPtr)
|
|||||||
wusleep(20000);
|
wusleep(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bPtr->flags.pushed = 0;
|
||||||
|
|
||||||
if (bPtr->groupIndex > 0) {
|
if (bPtr->groupIndex > 0) {
|
||||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||||
}
|
}
|
||||||
@@ -493,8 +495,6 @@ WMPerformButtonClick(WMButton *bPtr)
|
|||||||
if (bPtr->action)
|
if (bPtr->action)
|
||||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||||
|
|
||||||
bPtr->flags.pushed = 0;
|
|
||||||
|
|
||||||
if (bPtr->view->flags.mapped)
|
if (bPtr->view->flags.mapped)
|
||||||
paintButton(bPtr);
|
paintButton(bPtr);
|
||||||
}
|
}
|
||||||
@@ -728,17 +728,14 @@ handleActionEvents(XEvent *event, void *data)
|
|||||||
|
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
if (event->xbutton.button == Button1) {
|
if (event->xbutton.button == Button1) {
|
||||||
if (bPtr->groupIndex>0) {
|
bPtr->flags.prevSelected = bPtr->flags.selected;
|
||||||
if (!bPtr->flags.selected)
|
bPtr->flags.wasPushed = 0;
|
||||||
doclick = 1;
|
|
||||||
bPtr->flags.pushed = 1;
|
bPtr->flags.pushed = 1;
|
||||||
|
if (bPtr->groupIndex>0) {
|
||||||
bPtr->flags.selected = 1;
|
bPtr->flags.selected = 1;
|
||||||
dopaint = 1;
|
dopaint = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
bPtr->flags.wasPushed = 0;
|
|
||||||
bPtr->flags.pushed = 1;
|
|
||||||
bPtr->flags.prevSelected = bPtr->flags.selected;
|
|
||||||
bPtr->flags.selected = !bPtr->flags.selected;
|
bPtr->flags.selected = !bPtr->flags.selected;
|
||||||
dopaint = 1;
|
dopaint = 1;
|
||||||
|
|
||||||
@@ -752,7 +749,8 @@ handleActionEvents(XEvent *event, void *data)
|
|||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
if (event->xbutton.button == Button1) {
|
if (event->xbutton.button == Button1) {
|
||||||
if (bPtr->flags.pushed) {
|
if (bPtr->flags.pushed) {
|
||||||
if (bPtr->groupIndex==0)
|
if (bPtr->groupIndex==0 ||
|
||||||
|
bPtr->flags.selected && bPtr->groupIndex > 0)
|
||||||
doclick = 1;
|
doclick = 1;
|
||||||
dopaint = 1;
|
dopaint = 1;
|
||||||
if (bPtr->flags.springLoaded) {
|
if (bPtr->flags.springLoaded) {
|
||||||
|
|||||||
@@ -531,6 +531,9 @@ popUpMenu(PopUpButton *bPtr)
|
|||||||
Window dummyW;
|
Window dummyW;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
|
if (!bPtr->flags.enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!bPtr->menuView->flags.realized) {
|
if (!bPtr->menuView->flags.realized) {
|
||||||
W_RealizeView(bPtr->menuView);
|
W_RealizeView(bPtr->menuView);
|
||||||
resizeMenu(bPtr);
|
resizeMenu(bPtr);
|
||||||
@@ -553,6 +556,9 @@ popUpMenu(PopUpButton *bPtr)
|
|||||||
makeMenuPixmap(bPtr));
|
makeMenuPixmap(bPtr));
|
||||||
XClearWindow(scr->display, bPtr->menuView->window);
|
XClearWindow(scr->display, bPtr->menuView->window);
|
||||||
|
|
||||||
|
if (W_VIEW_WIDTH(bPtr->menuView) != W_VIEW_WIDTH(bPtr->view))
|
||||||
|
resizeMenu(bPtr);
|
||||||
|
|
||||||
W_MapView(bPtr->menuView);
|
W_MapView(bPtr->menuView);
|
||||||
|
|
||||||
bPtr->highlightedItem = 0;
|
bPtr->highlightedItem = 0;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ static void paintScrollView(ScrollView *sPtr);
|
|||||||
static void handleEvents(XEvent *event, void *data);
|
static void handleEvents(XEvent *event, void *data);
|
||||||
static void handleViewportEvents(XEvent *event, void *data);
|
static void handleViewportEvents(XEvent *event, void *data);
|
||||||
static void resizeScrollView();
|
static void resizeScrollView();
|
||||||
|
static void updateScrollerProportion();
|
||||||
|
|
||||||
W_ViewDelegate _ScrollViewViewDelegate = {
|
W_ViewDelegate _ScrollViewViewDelegate = {
|
||||||
NULL,
|
NULL,
|
||||||
@@ -64,21 +64,16 @@ WMCreateScrollView(WMWidget *parent)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sPtr->viewport = W_CreateView(sPtr->view);
|
sPtr->viewport = W_CreateView(sPtr->view);
|
||||||
if (!sPtr->view) {
|
if (!sPtr->viewport) {
|
||||||
W_DestroyView(sPtr->view);
|
W_DestroyView(sPtr->view);
|
||||||
wfree(sPtr);
|
wfree(sPtr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
sPtr->view->self = sPtr;
|
sPtr->view->self = sPtr;
|
||||||
|
sPtr->viewport->self = sPtr;
|
||||||
|
|
||||||
sPtr->view->delegate = &_ScrollViewViewDelegate;
|
sPtr->view->delegate = &_ScrollViewViewDelegate;
|
||||||
|
|
||||||
/* This has a very bad effect when the scrollview is mapped, making it
|
|
||||||
* flicker with each item added to it. It also seems to draw slower.
|
|
||||||
* Why should it be black anyway? -Dan
|
|
||||||
*/
|
|
||||||
/*W_SetViewBackgroundColor(sPtr->viewport,
|
|
||||||
WMBlackColor(WMWidgetScreen(parent)));*/
|
|
||||||
sPtr->viewport->flags.mapWhenRealized = 1;
|
sPtr->viewport->flags.mapWhenRealized = 1;
|
||||||
|
|
||||||
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
|
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
|
||||||
@@ -94,6 +89,45 @@ WMCreateScrollView(WMWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
applyScrollerValues(WMScrollView *sPtr)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
if (sPtr->contentView == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (sPtr->flags.hasHScroller) {
|
||||||
|
float v = WMGetScrollerValue(sPtr->hScroller);
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||||
|
|
||||||
|
x = v * size;
|
||||||
|
} else {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sPtr->flags.hasVScroller) {
|
||||||
|
float v = WMGetScrollerValue(sPtr->vScroller);
|
||||||
|
|
||||||
|
int size;
|
||||||
|
|
||||||
|
size = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||||
|
|
||||||
|
y = v * size;
|
||||||
|
} else {
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = WMAX(0, x);
|
||||||
|
y = WMAX(0, y);
|
||||||
|
|
||||||
|
W_MoveView(sPtr->contentView, -x, -y);
|
||||||
|
|
||||||
|
W_RaiseView(sPtr->viewport);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
reorganizeInterior(WMScrollView *sPtr)
|
reorganizeInterior(WMScrollView *sPtr)
|
||||||
@@ -122,7 +156,7 @@ reorganizeInterior(WMScrollView *sPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sPtr->flags.hasHScroller) {
|
if (sPtr->flags.hasHScroller) {
|
||||||
int h = W_VIEW(sPtr->hScroller)->size.height;
|
int h = 20;
|
||||||
|
|
||||||
ch -= h;
|
ch -= h;
|
||||||
|
|
||||||
@@ -144,7 +178,7 @@ reorganizeInterior(WMScrollView *sPtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sPtr->flags.hasVScroller) {
|
if (sPtr->flags.hasVScroller) {
|
||||||
int w = W_VIEW(sPtr->vScroller)->size.width;
|
int w = 20;
|
||||||
cw -= w;
|
cw -= w;
|
||||||
cx += w;
|
cx += w;
|
||||||
hx += w - 1;
|
hx += w - 1;
|
||||||
@@ -178,6 +212,8 @@ reorganizeInterior(WMScrollView *sPtr)
|
|||||||
WMResizeWidget(sPtr->vScroller, 20, vh);
|
WMResizeWidget(sPtr->vScroller, 20, vh);
|
||||||
WMMoveWidget(sPtr->vScroller, vx, vy);
|
WMMoveWidget(sPtr->vScroller, vx, vy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
applyScrollerValues(sPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,6 +221,7 @@ static void
|
|||||||
resizeScrollView(W_ViewDelegate *self, WMView *view)
|
resizeScrollView(W_ViewDelegate *self, WMView *view)
|
||||||
{
|
{
|
||||||
reorganizeInterior(view->self);
|
reorganizeInterior(view->self);
|
||||||
|
updateScrollerProportion(view->self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -209,11 +246,11 @@ WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sPtr->flags.hasVScroller) {
|
if (sPtr->flags.hasVScroller) {
|
||||||
w -= W_VIEW(sPtr->hScroller)->size.width;
|
width -= W_VIEW(sPtr->hScroller)->size.width;
|
||||||
WMResizeWidget(sPtr->vScroller, 20, h);
|
WMResizeWidget(sPtr->vScroller, 20, h);
|
||||||
}
|
}
|
||||||
if (sPtr->flags.hasHScroller) {
|
if (sPtr->flags.hasHScroller) {
|
||||||
h -= W_VIEW(sPtr->hScroller)->size.height;
|
height -= W_VIEW(sPtr->hScroller)->size.height;
|
||||||
WMResizeWidget(sPtr->hScroller, w, 20);
|
WMResizeWidget(sPtr->hScroller, w, 20);
|
||||||
WMMoveWidget(sPtr->hScroller, x, h);
|
WMMoveWidget(sPtr->hScroller, x, h);
|
||||||
}
|
}
|
||||||
@@ -247,12 +284,37 @@ WMGetScrollViewVisibleRect(WMScrollView *sPtr)
|
|||||||
{
|
{
|
||||||
WMRect rect;
|
WMRect rect;
|
||||||
|
|
||||||
rect.pos = sPtr->contentView->pos;
|
rect.pos.x = -sPtr->contentView->pos.x;
|
||||||
|
rect.pos.y = -sPtr->contentView->pos.y;
|
||||||
rect.size = sPtr->viewport->size;
|
rect.size = sPtr->viewport->size;
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
WMScrollViewScrollPoint(WMScrollView *sPtr, WMPoint point)
|
||||||
|
{
|
||||||
|
float xsize, ysize;
|
||||||
|
float xpos, ypos;
|
||||||
|
|
||||||
|
xsize = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||||
|
ysize = sPtr->contentView->size.height-sPtr->viewport->size.height;
|
||||||
|
|
||||||
|
xpos = point.x / xsize;
|
||||||
|
ypos = point.y / ysize;
|
||||||
|
|
||||||
|
if (sPtr->hScroller)
|
||||||
|
WMSetScrollerParameters(sPtr->hScroller, xpos,
|
||||||
|
WMGetScrollerKnobProportion(sPtr->hScroller));
|
||||||
|
if (sPtr->vScroller)
|
||||||
|
WMSetScrollerParameters(sPtr->vScroller, ypos,
|
||||||
|
WMGetScrollerKnobProportion(sPtr->vScroller));
|
||||||
|
|
||||||
|
W_MoveView(sPtr->contentView, -point.x, -point.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doScrolling(WMWidget *self, void *data)
|
doScrolling(WMWidget *self, void *data)
|
||||||
{
|
{
|
||||||
@@ -473,6 +535,7 @@ WMSetScrollViewRelief(WMScrollView *sPtr, WMReliefType type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
paintScrollView(ScrollView *sPtr)
|
paintScrollView(ScrollView *sPtr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -746,11 +746,14 @@ WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview)
|
|||||||
WMViewMoveDidChangeNotification,
|
WMViewMoveDidChangeNotification,
|
||||||
subview);
|
subview);
|
||||||
*/
|
*/
|
||||||
if (wasMapped)
|
if (wasMapped) {
|
||||||
W_MapView(subview);
|
W_MapView(subview);
|
||||||
|
|
||||||
sPtr->flags.adjustOnPaint = 1;
|
sPtr->flags.adjustOnPaint = 1;
|
||||||
paintSplitView(sPtr);
|
paintSplitView(sPtr);
|
||||||
|
} else {
|
||||||
|
handleViewResized(sPtr, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -844,10 +847,11 @@ WMSetSplitViewVertical(WMSplitView *sPtr, Bool flag)
|
|||||||
|
|
||||||
sPtr->flags.vertical = vertical;
|
sPtr->flags.vertical = vertical;
|
||||||
|
|
||||||
if (sPtr->view->flags.mapped && sPtr->view->flags.realized)
|
/* if (sPtr->view->flags.mapped && sPtr->view->flags.realized)*/
|
||||||
handleViewResized(sPtr, NULL);
|
handleViewResized(sPtr, NULL);
|
||||||
else
|
/* else
|
||||||
sPtr->flags.adjustOnPaint = 1;
|
sPtr->flags.adjustOnPaint = 1;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
253
WINGs/wtabview.c
253
WINGs/wtabview.c
@@ -22,7 +22,6 @@ typedef struct W_TabView {
|
|||||||
|
|
||||||
WMTabViewDelegate *delegate;
|
WMTabViewDelegate *delegate;
|
||||||
|
|
||||||
short tabWidth;
|
|
||||||
short tabHeight;
|
short tabHeight;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@@ -32,6 +31,8 @@ typedef struct W_TabView {
|
|||||||
|
|
||||||
unsigned tabbed:1;
|
unsigned tabbed:1;
|
||||||
unsigned dontFitAll:1;
|
unsigned dontFitAll:1;
|
||||||
|
unsigned bordered:1;
|
||||||
|
unsigned uniformTabs:1;
|
||||||
} flags;
|
} flags;
|
||||||
} TabView;
|
} TabView;
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ typedef struct W_TabView {
|
|||||||
#define DEFAULT_HEIGHT 40
|
#define DEFAULT_HEIGHT 40
|
||||||
|
|
||||||
#define NORMAL_SIDE_OFFSET 8
|
#define NORMAL_SIDE_OFFSET 8
|
||||||
#define BUTTONED_SIDE_OFFSET 20
|
#define BUTTONED_SIDE_OFFSET 15
|
||||||
|
|
||||||
|
|
||||||
static void destroyTabView(TabView *tPtr);
|
static void destroyTabView(TabView *tPtr);
|
||||||
@@ -61,8 +62,13 @@ static void W_MapTabViewItem(WMTabViewItem *item);
|
|||||||
|
|
||||||
static WMView *W_TabViewItemView(WMTabViewItem *item);
|
static WMView *W_TabViewItemView(WMTabViewItem *item);
|
||||||
|
|
||||||
static void recalcTabWidth(TabView *tPtr);
|
static int W_TabViewItemTabWidth(WMTabViewItem *item);
|
||||||
|
|
||||||
|
static void W_SetTabViewItemTabWidth(WMTabViewItem *item, int width);
|
||||||
|
|
||||||
|
|
||||||
|
static void recalcTabWidth(TabView *tPtr);
|
||||||
|
static void rearrange(TabView *tPtr);
|
||||||
|
|
||||||
static void didResize(struct W_ViewDelegate*, WMView*);
|
static void didResize(struct W_ViewDelegate*, WMView*);
|
||||||
|
|
||||||
@@ -75,6 +81,52 @@ static W_ViewDelegate delegate = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
positionOfTab(WMTabView *tabView, int tab)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int offs;
|
||||||
|
|
||||||
|
if (tab < tabView->firstVisible)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (tab > tabView->firstVisible + tabView->visibleTabs)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (tabView->flags.dontFitAll)
|
||||||
|
offs = BUTTONED_SIDE_OFFSET;
|
||||||
|
else
|
||||||
|
offs = NORMAL_SIDE_OFFSET;
|
||||||
|
|
||||||
|
for (i = tabView->firstVisible; i < tab; i++)
|
||||||
|
offs += W_TabViewItemTabWidth(tabView->items[i]) - 10;
|
||||||
|
|
||||||
|
return offs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
countVisibleTabs(TabView *tPtr, int first)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int width;
|
||||||
|
|
||||||
|
if (first < 0) {
|
||||||
|
width = W_VIEW_WIDTH(tPtr->view) - 2 * NORMAL_SIDE_OFFSET;
|
||||||
|
first = 0;
|
||||||
|
} else {
|
||||||
|
width = W_VIEW_WIDTH(tPtr->view) - 2 * BUTTONED_SIDE_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = first; i < tPtr->itemCount; i++) {
|
||||||
|
width -= W_TabViewItemTabWidth(tPtr->items[i]) - 10;
|
||||||
|
if (width <= 0) {
|
||||||
|
return i - first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i - first;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -100,21 +152,21 @@ handleEvents(XEvent *event, void *data)
|
|||||||
WMSelectTabViewItem(tPtr, item);
|
WMSelectTabViewItem(tPtr, item);
|
||||||
} else if (tPtr->flags.dontFitAll) {
|
} else if (tPtr->flags.dontFitAll) {
|
||||||
int redraw;
|
int redraw;
|
||||||
|
int lastVisible = tPtr->firstVisible+tPtr->visibleTabs-1;
|
||||||
|
|
||||||
if (event->xbutton.x < BUTTONED_SIDE_OFFSET) {
|
if (event->xbutton.x < BUTTONED_SIDE_OFFSET) {
|
||||||
if (tPtr->firstVisible > 0) {
|
if (tPtr->firstVisible > 0) {
|
||||||
redraw = 1;
|
redraw = 1;
|
||||||
tPtr->firstVisible--;
|
tPtr->firstVisible--;
|
||||||
}
|
}
|
||||||
} else if (event->xbutton.x - BUTTONED_SIDE_OFFSET
|
} else if (event->xbutton.x > positionOfTab(tPtr,lastVisible)){
|
||||||
> tPtr->visibleTabs*(tPtr->tabWidth-10)) {
|
|
||||||
|
|
||||||
if (tPtr->firstVisible + tPtr->visibleTabs
|
if (lastVisible < tPtr->itemCount-1) {
|
||||||
< tPtr->itemCount) {
|
|
||||||
redraw = 1;
|
redraw = 1;
|
||||||
tPtr->firstVisible++;
|
tPtr->firstVisible++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible);
|
||||||
if (redraw) {
|
if (redraw) {
|
||||||
paintTabView(tPtr);
|
paintTabView(tPtr);
|
||||||
}
|
}
|
||||||
@@ -154,6 +206,10 @@ WMCreateTabView(WMWidget *parent)
|
|||||||
|
|
||||||
tPtr->font = WMRetainFont(scr->normalFont);
|
tPtr->font = WMRetainFont(scr->normalFont);
|
||||||
|
|
||||||
|
tPtr->flags.type = WTTopTabsBevelBorder;
|
||||||
|
tPtr->flags.bordered = 1;
|
||||||
|
tPtr->flags.uniformTabs = 0;
|
||||||
|
|
||||||
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|
||||||
|ButtonPressMask, handleEvents, tPtr);
|
|ButtonPressMask, handleEvents, tPtr);
|
||||||
|
|
||||||
@@ -217,8 +273,8 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (index < tPtr->itemCount) {
|
if (index < tPtr->itemCount) {
|
||||||
memmove(&tPtr->items[index + 1], &tPtr->items[index],
|
memmove(tPtr->items + index + 1, tPtr->items + index,
|
||||||
tPtr->itemCount - index);
|
(tPtr->itemCount - index) * sizeof(WMTabViewItem*));
|
||||||
}
|
}
|
||||||
|
|
||||||
tPtr->items[index] = item;
|
tPtr->items[index] = item;
|
||||||
@@ -231,17 +287,28 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
|||||||
|
|
||||||
W_UnmapTabViewItem(item);
|
W_UnmapTabViewItem(item);
|
||||||
|
|
||||||
|
if (tPtr->flags.bordered) {
|
||||||
W_ReparentView(W_TabViewItemView(item), tPtr->view, 1,
|
W_ReparentView(W_TabViewItemView(item), tPtr->view, 1,
|
||||||
tPtr->tabHeight + 1);
|
tPtr->tabHeight + 1);
|
||||||
|
|
||||||
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 3,
|
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 3,
|
||||||
tPtr->view->size.height - tPtr->tabHeight - 3);
|
tPtr->view->size.height - tPtr->tabHeight - 3);
|
||||||
|
} else {
|
||||||
|
W_ReparentView(W_TabViewItemView(item), tPtr->view, 0,
|
||||||
|
tPtr->tabHeight);
|
||||||
|
|
||||||
|
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width,
|
||||||
|
tPtr->view->size.height - tPtr->tabHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
W_MapTabViewItem(item);
|
W_MapTabViewItem(item);
|
||||||
}
|
}
|
||||||
if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems)
|
if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems)
|
||||||
(*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr);
|
(*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr);
|
||||||
|
|
||||||
|
if (W_VIEW_REALIZED(tPtr->view))
|
||||||
|
paintTabView(tPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -304,28 +371,29 @@ WMTabViewItemAtPoint(WMTabView *tPtr, int x, int y)
|
|||||||
int first = tPtr->firstVisible;
|
int first = tPtr->firstVisible;
|
||||||
|
|
||||||
if (tPtr->flags.dontFitAll) {
|
if (tPtr->flags.dontFitAll) {
|
||||||
offset = BUTTONED_SIDE_OFFSET;
|
|
||||||
|
|
||||||
i = tPtr->selectedItem - tPtr->firstVisible;
|
i = tPtr->selectedItem - tPtr->firstVisible;
|
||||||
if (i >= 0 && i < tPtr->visibleTabs
|
if (i >= 0 && i < tPtr->visibleTabs
|
||||||
&& isInside(offset + (tPtr->tabWidth-10)*i, 0, tPtr->tabWidth,
|
&& isInside(positionOfTab(tPtr, tPtr->selectedItem), 0,
|
||||||
|
W_TabViewItemTabWidth(tPtr->items[tPtr->selectedItem]),
|
||||||
tPtr->tabHeight, x, y)) {
|
tPtr->tabHeight, x, y)) {
|
||||||
return tPtr->items[tPtr->selectedItem];
|
return tPtr->items[tPtr->selectedItem];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
offset = NORMAL_SIDE_OFFSET;
|
|
||||||
|
|
||||||
i = tPtr->selectedItem;
|
i = tPtr->selectedItem;
|
||||||
if (isInside(offset + (tPtr->tabWidth-10)*i, 0, tPtr->tabWidth,
|
if (isInside(positionOfTab(tPtr, i), 0,
|
||||||
|
W_TabViewItemTabWidth(tPtr->items[i]),
|
||||||
tPtr->tabHeight, x, y)) {
|
tPtr->tabHeight, x, y)) {
|
||||||
return tPtr->items[i];
|
return tPtr->items[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = first; i < first + count; i++) {
|
||||||
if (isInside(offset + (tPtr->tabWidth-10)*i, 0, tPtr->tabWidth,
|
int pos;
|
||||||
|
|
||||||
|
pos = positionOfTab(tPtr, i);
|
||||||
|
if (isInside(pos, 0, W_TabViewItemTabWidth(tPtr->items[i]),
|
||||||
tPtr->tabHeight, x, y)) {
|
tPtr->tabHeight, x, y)) {
|
||||||
return tPtr->items[i+first];
|
return tPtr->items[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -336,6 +404,18 @@ void
|
|||||||
WMSetTabViewType(WMTabView *tPtr, WMTabViewType type)
|
WMSetTabViewType(WMTabView *tPtr, WMTabViewType type)
|
||||||
{
|
{
|
||||||
tPtr->flags.type = type;
|
tPtr->flags.type = type;
|
||||||
|
|
||||||
|
if (type != WTTopTabsBevelBorder)
|
||||||
|
tPtr->tabHeight = 0;
|
||||||
|
else
|
||||||
|
tPtr->tabHeight = WMFontHeight(tPtr->font) + 3;
|
||||||
|
|
||||||
|
if (type == WTNoTabsNoBorder)
|
||||||
|
tPtr->flags.bordered = 0;
|
||||||
|
else
|
||||||
|
tPtr->flags.bordered = 1;
|
||||||
|
|
||||||
|
rearrange(tPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -429,6 +509,7 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
recalcTabWidth(TabView *tPtr)
|
recalcTabWidth(TabView *tPtr)
|
||||||
{
|
{
|
||||||
@@ -436,27 +517,54 @@ recalcTabWidth(TabView *tPtr)
|
|||||||
int twidth = W_VIEW(tPtr)->size.width;
|
int twidth = W_VIEW(tPtr)->size.width;
|
||||||
int width;
|
int width;
|
||||||
|
|
||||||
tPtr->tabWidth = 0;
|
if (tPtr->flags.uniformTabs) {
|
||||||
|
int tabWidth;
|
||||||
|
|
||||||
|
tabWidth = 0;
|
||||||
|
|
||||||
for (i = 0; i < tPtr->itemCount; i++) {
|
for (i = 0; i < tPtr->itemCount; i++) {
|
||||||
char *str = WMGetTabViewItemLabel(tPtr->items[i]);
|
char *str = WMGetTabViewItemLabel(tPtr->items[i]);
|
||||||
|
|
||||||
if (str) {
|
if (str) {
|
||||||
width = WMWidthOfString(tPtr->font, str, strlen(str));
|
width = WMWidthOfString(tPtr->font, str, strlen(str));
|
||||||
if (width > tPtr->tabWidth)
|
if (width > tabWidth)
|
||||||
tPtr->tabWidth = width;
|
tabWidth = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tPtr->tabWidth += 30;
|
|
||||||
if ((tPtr->tabWidth + 2) * tPtr->itemCount > twidth - 2*NORMAL_SIDE_OFFSET) {
|
tabWidth = tabWidth + 30;
|
||||||
|
|
||||||
|
for (i = 0; i < tPtr->itemCount; i++)
|
||||||
|
W_SetTabViewItemTabWidth(tPtr->items[i], tabWidth);
|
||||||
|
|
||||||
|
tPtr->firstVisible = 0;
|
||||||
|
tPtr->visibleTabs = countVisibleTabs(tPtr, -1);
|
||||||
|
if (tPtr->visibleTabs < tPtr->itemCount)
|
||||||
|
tPtr->flags.dontFitAll = 1;
|
||||||
|
else
|
||||||
|
tPtr->flags.dontFitAll = 0;
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < tPtr->itemCount; i++) {
|
||||||
|
char *str = WMGetTabViewItemLabel(tPtr->items[i]);
|
||||||
|
if (!str)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
width = WMWidthOfString(tPtr->font, str, strlen(str)) + 30;
|
||||||
|
|
||||||
|
W_SetTabViewItemTabWidth(tPtr->items[i], width);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (countVisibleTabs(tPtr, -1) < tPtr->itemCount) {
|
||||||
tPtr->flags.dontFitAll = 1;
|
tPtr->flags.dontFitAll = 1;
|
||||||
tPtr->firstVisible = 0;
|
tPtr->firstVisible = 0;
|
||||||
tPtr->visibleTabs = (twidth - 2*BUTTONED_SIDE_OFFSET) / (tPtr->tabWidth-10);
|
tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible);
|
||||||
} else {
|
} else {
|
||||||
tPtr->flags.dontFitAll = 0;
|
tPtr->flags.dontFitAll = 0;
|
||||||
tPtr->firstVisible = 0;
|
tPtr->firstVisible = 0;
|
||||||
tPtr->visibleTabs = tPtr->itemCount;
|
tPtr->visibleTabs = tPtr->itemCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -552,27 +660,27 @@ paintTabView(TabView *tPtr)
|
|||||||
Display *dpy = scr->display;
|
Display *dpy = scr->display;
|
||||||
GC white = WMColorGC(scr->white);
|
GC white = WMColorGC(scr->white);
|
||||||
int i;
|
int i;
|
||||||
WMRect rect;
|
|
||||||
|
|
||||||
if (tPtr->flags.type == WTTopTabsBevelBorder) {
|
if (tPtr->flags.type == WTTopTabsBevelBorder) {
|
||||||
int count = tPtr->visibleTabs;
|
int count = tPtr->visibleTabs;
|
||||||
int first = tPtr->firstVisible;
|
int first = tPtr->firstVisible;
|
||||||
int offs;
|
|
||||||
int moreAtLeft;
|
int moreAtLeft;
|
||||||
int moreAtRight;
|
int moreAtRight;
|
||||||
int selectedIsVisible;
|
int selectedIsVisible;
|
||||||
|
int tx, ty;
|
||||||
|
int twidth, theight;
|
||||||
|
|
||||||
|
ty = 2;
|
||||||
|
theight = tPtr->tabHeight;
|
||||||
|
|
||||||
buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window,
|
buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window,
|
||||||
W_VIEW(tPtr)->size.width, tPtr->tabHeight,
|
W_VIEW(tPtr)->size.width, theight,
|
||||||
W_VIEW(tPtr)->screen->depth);
|
W_VIEW(tPtr)->screen->depth);
|
||||||
|
|
||||||
XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor),
|
XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor),
|
||||||
0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight);
|
0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight);
|
||||||
|
|
||||||
rect.pos.y = 2;
|
|
||||||
if (tPtr->flags.dontFitAll) {
|
if (tPtr->flags.dontFitAll) {
|
||||||
rect.pos.x = 15 + BUTTONED_SIDE_OFFSET;
|
|
||||||
offs = BUTTONED_SIDE_OFFSET;
|
|
||||||
moreAtLeft = first > 0;
|
moreAtLeft = first > 0;
|
||||||
moreAtRight = (first + count) < tPtr->itemCount;
|
moreAtRight = (first + count) < tPtr->itemCount;
|
||||||
if (tPtr->selectedItem >= first
|
if (tPtr->selectedItem >= first
|
||||||
@@ -581,44 +689,55 @@ paintTabView(TabView *tPtr)
|
|||||||
else
|
else
|
||||||
selectedIsVisible = 0;
|
selectedIsVisible = 0;
|
||||||
} else {
|
} else {
|
||||||
rect.pos.x = 15 + NORMAL_SIDE_OFFSET;
|
|
||||||
offs = NORMAL_SIDE_OFFSET;
|
|
||||||
moreAtLeft = 0;
|
moreAtLeft = 0;
|
||||||
moreAtRight = 0;
|
moreAtRight = 0;
|
||||||
selectedIsVisible = 1;
|
selectedIsVisible = 1;
|
||||||
}
|
}
|
||||||
rect.size.width = tPtr->tabWidth;
|
|
||||||
rect.size.height = tPtr->tabHeight;
|
|
||||||
|
|
||||||
for (i = count - (moreAtRight ? 0 : 1);
|
if (moreAtRight) {
|
||||||
i >= (moreAtLeft ? -1 : 0); i--) {
|
drawTab(tPtr, buffer, positionOfTab(tPtr, first+count), 0,
|
||||||
if (!selectedIsVisible || i != (tPtr->selectedItem-first)) {
|
W_VIEW_WIDTH(tPtr->view), theight, False);
|
||||||
drawTab(tPtr, buffer, offs + (rect.size.width-10)*i, 0,
|
|
||||||
rect.size.width, rect.size.height, False);
|
|
||||||
}
|
}
|
||||||
|
for (i = first + count-1; i >= first; i--) {
|
||||||
|
if (!selectedIsVisible || i != tPtr->selectedItem) {
|
||||||
|
twidth = W_TabViewItemTabWidth(tPtr->items[i]);
|
||||||
|
|
||||||
|
drawTab(tPtr, buffer, positionOfTab(tPtr, i), 0,
|
||||||
|
twidth, theight, False);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (moreAtLeft) {
|
||||||
|
drawTab(tPtr, buffer, positionOfTab(tPtr, 0)-2*BUTTONED_SIDE_OFFSET,
|
||||||
|
0, BUTTONED_SIDE_OFFSET*4, theight, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedIsVisible) {
|
if (selectedIsVisible) {
|
||||||
drawTab(tPtr, buffer,
|
int idx = tPtr->selectedItem;
|
||||||
offs + (rect.size.width-10) * (tPtr->selectedItem - first),
|
|
||||||
0, rect.size.width, rect.size.height, True);
|
|
||||||
|
|
||||||
XDrawLine(dpy, buffer, white, 0, tPtr->tabHeight - 1,
|
drawTab(tPtr, buffer, positionOfTab(tPtr, idx),
|
||||||
offs, tPtr->tabHeight - 1);
|
0, W_TabViewItemTabWidth(tPtr->items[idx]),
|
||||||
|
theight, True);
|
||||||
|
|
||||||
|
XDrawLine(dpy, buffer, white, 0, theight - 1,
|
||||||
|
positionOfTab(tPtr, idx), theight - 1);
|
||||||
|
|
||||||
XDrawLine(dpy, buffer, white,
|
XDrawLine(dpy, buffer, white,
|
||||||
offs + 10 + (rect.size.width-10) * count,
|
positionOfTab(tPtr, idx) + W_TabViewItemTabWidth(tPtr->items[idx]),
|
||||||
tPtr->tabHeight - 1, W_VIEW(tPtr)->size.width - 1,
|
tPtr->tabHeight - 1, W_VIEW_WIDTH(tPtr->view) - 1,
|
||||||
tPtr->tabHeight - 1);
|
tPtr->tabHeight - 1);
|
||||||
} else {
|
} else {
|
||||||
XDrawLine(dpy, buffer, white, 0, tPtr->tabHeight - 1,
|
XDrawLine(dpy, buffer, white, 0, theight - 1,
|
||||||
W_VIEW(tPtr)->size.width, tPtr->tabHeight - 1);
|
W_VIEW_WIDTH(tPtr->view), theight - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
W_DrawLabel(tPtr->items[first+i], buffer, rect);
|
WMRect rect;
|
||||||
|
|
||||||
rect.pos.x += rect.size.width - 10;
|
rect.pos.x = 15 + positionOfTab(tPtr, first+i);
|
||||||
|
rect.pos.y = ty;
|
||||||
|
rect.size.width = W_TabViewItemTabWidth(tPtr->items[first+i]);
|
||||||
|
rect.size.height = theight;
|
||||||
|
W_DrawLabel(tPtr->items[first+i], buffer, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (moreAtLeft) {
|
if (moreAtLeft) {
|
||||||
@@ -629,17 +748,16 @@ paintTabView(TabView *tPtr)
|
|||||||
if (moreAtRight) {
|
if (moreAtRight) {
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
x = BUTTONED_SIDE_OFFSET - 5 + tPtr->visibleTabs * (tPtr->tabWidth - 10);
|
x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs);
|
||||||
|
|
||||||
x = x + (W_VIEW(tPtr)->size.width - x)/2;
|
|
||||||
|
|
||||||
|
x = x + (W_VIEW_WIDTH(tPtr->view) - x)/2;
|
||||||
paintDot(tPtr, buffer, x + 5, 10);
|
paintDot(tPtr, buffer, x + 5, 10);
|
||||||
paintDot(tPtr, buffer, x + 8, 10);
|
paintDot(tPtr, buffer, x + 8, 10);
|
||||||
paintDot(tPtr, buffer, x + 11, 10);
|
paintDot(tPtr, buffer, x + 11, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0,
|
XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0,
|
||||||
W_VIEW(tPtr)->size.width, tPtr->tabHeight, 0, 0);
|
W_VIEW_WIDTH(tPtr->view), theight, 0, 0);
|
||||||
|
|
||||||
XFreePixmap(dpy, buffer);
|
XFreePixmap(dpy, buffer);
|
||||||
}
|
}
|
||||||
@@ -671,13 +789,16 @@ rearrange(TabView *tPtr)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
int bordered = tPtr->flags.bordered;
|
||||||
|
|
||||||
recalcTabWidth(tPtr);
|
recalcTabWidth(tPtr);
|
||||||
|
|
||||||
width = tPtr->view->size.width - 3;
|
width = tPtr->view->size.width - (bordered ? 3 : 0);
|
||||||
height = tPtr->view->size.height - tPtr->tabHeight - 3;
|
height = tPtr->view->size.height - tPtr->tabHeight - (bordered ? 3 : 0);
|
||||||
|
|
||||||
for (i = 0; i < tPtr->itemCount; i++) {
|
for (i = 0; i < tPtr->itemCount; i++) {
|
||||||
|
W_MoveView(W_TabViewItemView(tPtr->items[i]),
|
||||||
|
1*bordered, tPtr->tabHeight + 1*bordered);
|
||||||
W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height);
|
W_ResizeView(W_TabViewItemView(tPtr->items[i]), width, height);
|
||||||
}
|
}
|
||||||
if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view))
|
if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view))
|
||||||
@@ -720,6 +841,7 @@ typedef struct W_TabViewItem {
|
|||||||
|
|
||||||
char *label;
|
char *label;
|
||||||
|
|
||||||
|
short tabWidth;
|
||||||
int identifier;
|
int identifier;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@@ -778,6 +900,20 @@ W_TabViewItemView(WMTabViewItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
W_TabViewItemTabWidth(WMTabViewItem *item)
|
||||||
|
{
|
||||||
|
return item->tabWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
W_SetTabViewItemTabWidth(WMTabViewItem *item, int width)
|
||||||
|
{
|
||||||
|
item->tabWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
WMTabViewItem*
|
WMTabViewItem*
|
||||||
WMCreateTabViewItemWithIdentifier(int identifier)
|
WMCreateTabViewItemWithIdentifier(int identifier)
|
||||||
{
|
{
|
||||||
@@ -833,7 +969,10 @@ WMSetTabViewItemLabel(WMTabViewItem *item, char *label)
|
|||||||
if (item->label)
|
if (item->label)
|
||||||
wfree(item->label);
|
wfree(item->label);
|
||||||
|
|
||||||
|
if (label)
|
||||||
item->label = wstrdup(label);
|
item->label = wstrdup(label);
|
||||||
|
else
|
||||||
|
item->label = NULL;
|
||||||
|
|
||||||
if (item->tabView)
|
if (item->tabView)
|
||||||
recalcTabWidth(item->tabView);
|
recalcTabWidth(item->tabView);
|
||||||
|
|||||||
@@ -1730,6 +1730,9 @@ y = tPtr->docHeight+ss-sd;
|
|||||||
|
|
||||||
if(items && itemsSize > 0)
|
if(items && itemsSize > 0)
|
||||||
wfree(items);
|
wfree(items);
|
||||||
|
|
||||||
|
if (W_VIEW_REALIZED(tPtr->view) && W_VIEW_MAPPED(tPtr->view))
|
||||||
|
paintText(tPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3445,7 +3448,7 @@ WMRemoveTextBlock(WMText *tPtr)
|
|||||||
|
|
||||||
if (!tPtr || !tPtr->firstTextBlock || !tPtr->lastTextBlock
|
if (!tPtr || !tPtr->firstTextBlock || !tPtr->lastTextBlock
|
||||||
|| !tPtr->currentTextBlock) {
|
|| !tPtr->currentTextBlock) {
|
||||||
printf("cannot remove non existent TextBlock!\b");
|
/* printf("cannot remove non existent TextBlock!\n"); */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -545,6 +545,8 @@ W_RedisplayView(W_View *view)
|
|||||||
ev.xexpose.window = view->window;
|
ev.xexpose.window = view->window;
|
||||||
ev.xexpose.count = 0;
|
ev.xexpose.count = 0;
|
||||||
|
|
||||||
|
ev.xexpose.serial = 0;
|
||||||
|
|
||||||
WMHandleEvent(&ev);
|
WMHandleEvent(&ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -665,11 +665,20 @@ handleEvents(XEvent *event, void *clientData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
/*
|
||||||
|
// was causing windows to ignore commands like closeWindow
|
||||||
|
* // after the windows is iconized/restored or a workspace change
|
||||||
|
* // if this is really needed, put the MapNotify portion too and
|
||||||
|
* // fix the restack bug in wmaker
|
||||||
case UnmapNotify:
|
case UnmapNotify:
|
||||||
WMUnmapWidget(win);
|
WMUnmapWidget(win);
|
||||||
break;
|
break;
|
||||||
|
*
|
||||||
|
case MapNotify:
|
||||||
|
WMMapWidget(win);
|
||||||
|
break;
|
||||||
|
|
||||||
|
*/
|
||||||
case DestroyNotify:
|
case DestroyNotify:
|
||||||
destroyWindow(win);
|
destroyWindow(win);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user