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.
|
||||
- added WMBox widget
|
||||
- added W_SetViewCursor()
|
||||
- made Extra widgets library
|
||||
- added table widget in Extras library
|
||||
- added WMGetConnectionUnsentData() (WMGetConnectionQueuedData() too as an
|
||||
alias).
|
||||
- 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).
|
||||
|
||||
|
||||
|
||||
changes since wmaker 0.62.0:
|
||||
............................
|
||||
- added WMSetWidgetDefaultFont(), WMSetWidgetDefaultBoldFont()
|
||||
|
||||
@@ -14,6 +14,13 @@ typedef struct {
|
||||
} StringData;
|
||||
|
||||
|
||||
typedef struct {
|
||||
WMTableView *table;
|
||||
GC selGc;
|
||||
} PixmapData;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
WMTextField *widget;
|
||||
WMTableView *table;
|
||||
@@ -36,6 +43,17 @@ typedef struct {
|
||||
} 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,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
@@ -124,9 +185,10 @@ static void beginSECellEdit(WMTableColumnDelegate *self,
|
||||
static void endSECellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
char *text;
|
||||
|
||||
WMUnmapWidget(strdata->widget);
|
||||
|
||||
text = WMGetTextFieldText(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)text);
|
||||
@@ -145,8 +207,8 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
0, 0);
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->selGc = WMColorGC(WMDarkGrayColor(scr));
|
||||
data->selTextGc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||
data->gc = WMColorGC(WMBlackColor(scr));
|
||||
|
||||
delegate->data = data;
|
||||
@@ -168,7 +230,7 @@ static void ESCellPainter(WMTableColumnDelegate *self,
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = WMTableViewDataForCell(table, column, row);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
|
||||
stringDraw(WMWidgetScreen(table),
|
||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||
@@ -184,7 +246,7 @@ static void selectedESCellPainter(WMTableColumnDelegate *self,
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = WMTableViewDataForCell(table, column, row);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
|
||||
stringDraw(WMWidgetScreen(table),
|
||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||
@@ -206,8 +268,8 @@ static void beginESCellEdit(WMTableColumnDelegate *self,
|
||||
|
||||
WMSetPopUpButtonSelectedItem(strdata->widget, data);
|
||||
|
||||
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y-1);
|
||||
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+2);
|
||||
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y);
|
||||
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+1);
|
||||
|
||||
WMMapWidget(strdata->widget);
|
||||
}
|
||||
@@ -216,9 +278,10 @@ static void beginESCellEdit(WMTableColumnDelegate *self,
|
||||
static void endESCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
int option;
|
||||
|
||||
WMUnmapWidget(strdata->widget);
|
||||
|
||||
option = WMGetPopUpButtonSelectedItem(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)option);
|
||||
@@ -237,8 +300,8 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
0, 0);
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->selGc = WMColorGC(WMDarkGrayColor(scr));
|
||||
data->selTextGc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||
data->gc = WMColorGC(WMBlackColor(scr));
|
||||
data->count = 0;
|
||||
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->font = WMSystemFontOfSize(scr, 12);
|
||||
data->selGc = WMColorGC(WMDarkGrayColor(scr));
|
||||
data->selTextGc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGc = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->selTextGc = WMColorGC(WMBlackColor(scr));
|
||||
data->gc = WMColorGC(WMBlackColor(scr));
|
||||
|
||||
delegate->data = data;
|
||||
@@ -327,3 +492,134 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
||||
|
||||
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,10 +6,18 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table);
|
||||
WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *table);
|
||||
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table);
|
||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table);
|
||||
WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent);
|
||||
|
||||
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table);
|
||||
|
||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table);
|
||||
void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
char **options, int count);
|
||||
|
||||
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -60,10 +60,10 @@ 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);
|
||||
}
|
||||
|
||||
@@ -98,12 +98,10 @@ main(int argc, char **argv)
|
||||
table = WMCreateTableView(win);
|
||||
WMResizeWidget(table, 400, 200);
|
||||
WMSetTableViewBackgroundColor(table, WMWhiteColor(scr));
|
||||
WMSetTableViewGridColor(table, WMGrayColor(scr));
|
||||
// WMSetTableViewGridColor(table, WMGrayColor(scr));
|
||||
WMSetTableViewHeaderHeight(table, 20);
|
||||
WMSetTableViewDelegate(table, &delegate);
|
||||
WMAddNotificationObserver(selectedRowObserver, table,
|
||||
WMTableViewRowWasSelectedNotification,
|
||||
table);
|
||||
WMSetTableViewAction(table, clickedTable, table);
|
||||
|
||||
colDeleg = WTCreateStringEditorDelegate(table);
|
||||
|
||||
@@ -122,6 +120,15 @@ main(int argc, char **argv)
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
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);
|
||||
WMRealizeWidget(win);
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
#include "wtableview.h"
|
||||
|
||||
|
||||
const char *WMTableViewRowWasSelectedNotification = "WMTableViewRowWasSelectedNotification";
|
||||
const char *WMTableViewRowWasUnselectedNotification = "WMTableViewRowWasUnselectedNotification";
|
||||
const char *WMTableViewSelectionDidChangeNotification = "WMTableViewSelectionDidChangeNotification";
|
||||
|
||||
|
||||
struct W_TableColumn {
|
||||
@@ -30,6 +29,10 @@ struct W_TableColumn {
|
||||
|
||||
static void handleResize(W_ViewDelegate *self, WMView *view);
|
||||
|
||||
static void rearrangeHeader(WMTableView *table);
|
||||
|
||||
static WMRange rowsInRect(WMTableView *table, WMRect rect);
|
||||
|
||||
|
||||
WMTableColumn *WMCreateTableColumn(char *title)
|
||||
{
|
||||
@@ -72,9 +75,9 @@ void WMSetTableColumnWidth(WMTableColumn *column, unsigned width)
|
||||
column->width = WMAX(column->minWidth, width);
|
||||
else
|
||||
column->width = WMAX(column->minWidth, WMIN(column->maxWidth, width));
|
||||
|
||||
|
||||
if (column->table) {
|
||||
handleResize(NULL, W_VIEW(column->table));
|
||||
rearrangeHeader(column->table);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,12 +146,19 @@ struct W_TableView {
|
||||
|
||||
WMTableViewDelegate *delegate;
|
||||
|
||||
WMAction *action;
|
||||
void *clientData;
|
||||
|
||||
void *clickedColumn;
|
||||
int clickedRow;
|
||||
|
||||
int editingRow;
|
||||
|
||||
unsigned headerHeight;
|
||||
|
||||
unsigned rowHeight;
|
||||
|
||||
|
||||
unsigned dragging:1;
|
||||
unsigned drawsGrid:1;
|
||||
unsigned canSelectRow:1;
|
||||
unsigned canSelectMultiRows:1;
|
||||
@@ -188,13 +198,13 @@ static void scrollObserver(void *self, WMNotification *notif)
|
||||
|
||||
column = WMGetFromArray(table->columns, i);
|
||||
|
||||
WMMoveWidget(column->titleW, x + rect.pos.x, 0);
|
||||
WMMoveWidget(column->titleW, x - rect.pos.x, 0);
|
||||
|
||||
if (i > 0) {
|
||||
WMView *splitter;
|
||||
|
||||
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;
|
||||
@@ -268,6 +278,7 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
||||
WMMoveWidget(table->header, 22, 2);
|
||||
WMMapWidget(table->header);
|
||||
WMSetFrameRelief(table->header, WRFlat);
|
||||
|
||||
table->corner = WMCreateLabel(table);
|
||||
WMResizeWidget(table->corner, 20, table->headerHeight);
|
||||
WMMoveWidget(table->corner, 2, 2);
|
||||
@@ -287,7 +298,8 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
||||
|
||||
table->tableView->flags.dontCompressExpose = 1;
|
||||
|
||||
table->gridColor = WMDarkGrayColor(scr);
|
||||
table->gridColor = WMCreateNamedColor(scr, "#cccccc", False);
|
||||
/* table->gridColor = WMGrayColor(scr);*/
|
||||
|
||||
{
|
||||
XGCValues gcv;
|
||||
@@ -300,10 +312,13 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
||||
}
|
||||
|
||||
table->editingRow = -1;
|
||||
table->clickedRow = -1;
|
||||
|
||||
table->drawsGrid = 1;
|
||||
table->rowHeight = 16;
|
||||
|
||||
WMSetScrollViewLineScroll(table->scrollView, table->rowHeight);
|
||||
|
||||
table->tableWidth = 1;
|
||||
|
||||
table->columns = WMCreateArray(4);
|
||||
@@ -319,7 +334,8 @@ WMTableView *WMCreateTableView(WMWidget *parent)
|
||||
WMCreateEventHandler(table->view, ExposureMask|StructureNotifyMask,
|
||||
handleEvents, table);
|
||||
|
||||
WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask,
|
||||
WMCreateEventHandler(table->tableView, ExposureMask|ButtonPressMask|
|
||||
ButtonReleaseMask|ButtonMotionMask,
|
||||
handleTableEvents, table);
|
||||
|
||||
return table;
|
||||
@@ -379,29 +395,7 @@ void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column)
|
||||
WMAddToArray(table->splitters, splitter);
|
||||
}
|
||||
|
||||
count = WMGetArrayItemCount(table->columns);
|
||||
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;
|
||||
rearrangeHeader(table);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
return table->tableView;
|
||||
@@ -486,11 +500,46 @@ void WMSetTableViewGridColor(WMTableView *table, WMColor *color)
|
||||
{
|
||||
WMReleaseColor(table->gridColor);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void drawGrid(WMTableView *table, WMRect rect)
|
||||
{
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
@@ -580,9 +629,12 @@ static WMRange rowsInRect(WMTableView *table, WMRect rect)
|
||||
{
|
||||
WMRange range;
|
||||
int rh = table->rowHeight;
|
||||
int dif;
|
||||
|
||||
range.position = WMAX(0, rect.pos.y / rh - 1);
|
||||
range.count = WMAX(1, WMIN(rect.size.height / rh + 3, table->rows));
|
||||
dif = rect.pos.y % rh;
|
||||
|
||||
range.position = WMAX(0, (rect.pos.y - dif) / rh);
|
||||
range.count = WMAX(1, WMIN((rect.size.height + dif) / rh, table->rows));
|
||||
|
||||
return range;
|
||||
}
|
||||
@@ -630,30 +682,14 @@ static void setRowSelected(WMTableView *table, unsigned row, Bool flag)
|
||||
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 (!flag) {
|
||||
WMRemoveFromArray(table->selectedRows, (void*)row);
|
||||
WMPostNotificationName(WMTableViewRowWasUnselectedNotification,
|
||||
table, (void*)row);
|
||||
repaint = 1;
|
||||
}
|
||||
} else {
|
||||
if (flag) {
|
||||
WMAddToArray(table->selectedRows, (void*)row);
|
||||
WMPostNotificationName(WMTableViewRowWasSelectedNotification,
|
||||
table, (void*)row);
|
||||
repaint = 1;
|
||||
}
|
||||
}
|
||||
@@ -690,7 +726,7 @@ static void repaintTable(WMTableView *table, int x, int y,
|
||||
|
||||
rows = rowsInRect(table, rect);
|
||||
for (i = rows.position;
|
||||
i < WMIN(rows.position+rows.count, table->rows);
|
||||
i < WMIN(rows.position+rows.count + 1, table->rows);
|
||||
i++) {
|
||||
drawRow(table, i, rect);
|
||||
}
|
||||
@@ -706,9 +742,8 @@ static void stopRowEdit(WMTableView *table, int row)
|
||||
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
||||
column = WMGetFromArray(table->columns, i);
|
||||
|
||||
wassertr(column->delegate && column->delegate->endCellEdit);
|
||||
|
||||
(*column->delegate->endCellEdit)(column->delegate, column, row);
|
||||
if (column->delegate && column->delegate->endCellEdit)
|
||||
(*column->delegate->endCellEdit)(column->delegate, column, row);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -727,27 +762,85 @@ void WMEditTableViewRow(WMTableView *table, int row)
|
||||
for (i = 0; i < WMGetArrayItemCount(table->columns); i++) {
|
||||
column = WMGetFromArray(table->columns, i);
|
||||
|
||||
wassertr(column->delegate && column->delegate->beginCellEdit);
|
||||
|
||||
(*column->delegate->beginCellEdit)(column->delegate, column, row);
|
||||
if (column->delegate && column->delegate->beginCellEdit)
|
||||
(*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)
|
||||
{
|
||||
WMTableView *table = (WMTableView*)data;
|
||||
int row;
|
||||
|
||||
switch (event->type) {
|
||||
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;
|
||||
|
||||
case Expose:
|
||||
repaintTable(table, event->xexpose.x, event->xexpose.y,
|
||||
event->xexpose.width, event->xexpose.height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -761,6 +854,13 @@ static void handleEvents(XEvent *event, void *data)
|
||||
W_DrawRelief(scr, W_VIEW_DRAWABLE(table->view), 0, 0,
|
||||
W_VIEW_WIDTH(table->view), W_VIEW_HEIGHT(table->view),
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
extern const char *WMTableViewRowWasSelectedNotification;
|
||||
extern const char *WMTableViewRowWasUnselectedNotification;
|
||||
extern const char *WMTableViewSelectionDidChangeNotification;
|
||||
|
||||
|
||||
typedef struct WMTableColumnDelegate {
|
||||
@@ -25,7 +24,7 @@ typedef struct WMTableColumnDelegate {
|
||||
void (*beginCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row);
|
||||
void (*endCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row);
|
||||
int row);
|
||||
} WMTableColumnDelegate;
|
||||
|
||||
|
||||
@@ -50,6 +49,7 @@ void WMSetTableColumnWidth(WMTableColumn *column, unsigned width);
|
||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||
WMTableColumnDelegate *delegate);
|
||||
|
||||
|
||||
WMTableView *WMGetTableColumnTableView(WMTableColumn *column);
|
||||
|
||||
void WMSetTableColumnId(WMTableColumn *column, void *id);
|
||||
@@ -70,10 +70,19 @@ void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column);
|
||||
|
||||
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);
|
||||
|
||||
void WMEditTableViewRow(WMTableView *table, int row);
|
||||
|
||||
|
||||
void WMSelectTableViewRow(WMTableView *table, int row);
|
||||
|
||||
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
|
||||
@@ -87,6 +96,13 @@ void WMSetTableViewBackgroundColor(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
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -579,7 +579,7 @@ testText(WMScreen *scr)
|
||||
{
|
||||
WMWindow *win;
|
||||
WMText *text;
|
||||
FILE *file = fopen("../README", "r");
|
||||
FILE *file = fopen("wm.html", "r");
|
||||
|
||||
windowCount++;
|
||||
|
||||
@@ -1231,7 +1231,7 @@ main(int argc, char **argv)
|
||||
|
||||
|
||||
/* Initialize the application */
|
||||
WMInitializeApplication("Test", &argc, argv);
|
||||
WMInitializeApplication("Test@eqweq_ewq$eqw", &argc, argv);
|
||||
|
||||
testUD();
|
||||
|
||||
@@ -1273,10 +1273,11 @@ main(int argc, char **argv)
|
||||
* Put the testSomething() function you want to test here.
|
||||
*/
|
||||
|
||||
testBox(scr);
|
||||
|
||||
#if 0
|
||||
testTabView(scr);
|
||||
#if 0
|
||||
testBox(scr);
|
||||
testText(scr);
|
||||
testList(scr);
|
||||
|
||||
testProgressIndicator(scr);
|
||||
@@ -1284,7 +1285,6 @@ main(int argc, char **argv)
|
||||
testColorWell(scr);
|
||||
|
||||
testTextField(scr);
|
||||
testText(scr);
|
||||
|
||||
testDragAndDrop(scr);
|
||||
testDragAndDrop(scr);
|
||||
|
||||
@@ -1611,6 +1611,8 @@ void WMDestroyTextBlock(WMText *tPtr, void *vtb);
|
||||
|
||||
WMTabView *WMCreateTabView(WMWidget *parent);
|
||||
|
||||
void WMSetTabViewType(WMTabView *tPtr, WMTabViewType type);
|
||||
|
||||
void WMSetTabViewFont(WMTabView *tPtr, WMFont *font);
|
||||
|
||||
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,
|
||||
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);
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
@@ -294,18 +294,18 @@ void WMFreeHashTable(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
|
||||
* 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);
|
||||
|
||||
/* warning: do not manipulate the table while using these functions */
|
||||
WMHashEnumerator WMEnumerateHashTable(WMHashTable *table);
|
||||
|
||||
void* WMNextHashEnumeratorItem(WMHashEnumerator *enumerator);
|
||||
const void* WMNextHashEnumeratorItem(WMHashEnumerator *enumerator);
|
||||
|
||||
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);
|
||||
|
||||
@@ -581,20 +581,20 @@ void* WMGetNotificationClientData(WMNotification *notification);
|
||||
|
||||
void* WMGetNotificationObject(WMNotification *notification);
|
||||
|
||||
char* WMGetNotificationName(WMNotification *notification);
|
||||
const char* WMGetNotificationName(WMNotification *notification);
|
||||
|
||||
|
||||
void WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
void *observer, char *name, void *object);
|
||||
void *observer, const char *name, void *object);
|
||||
|
||||
void WMPostNotification(WMNotification *notification);
|
||||
|
||||
void WMRemoveNotificationObserver(void *observer);
|
||||
|
||||
void WMRemoveNotificationObserverWithName(void *observer, char *name,
|
||||
void WMRemoveNotificationObserverWithName(void *observer, const char *name,
|
||||
void *object);
|
||||
|
||||
void WMPostNotificationName(char *name, void *object, void *clientData);
|
||||
void WMPostNotificationName(const char *name, void *object, void *clientData);
|
||||
|
||||
WMNotificationQueue* WMGetDefaultNotificationQueue(void);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
|
||||
typedef struct HashItem {
|
||||
void *key;
|
||||
void *data;
|
||||
const void *key;
|
||||
const void *data;
|
||||
|
||||
struct HashItem *next; /* collided item list */
|
||||
} HashItem;
|
||||
@@ -186,7 +186,7 @@ WMFreeHashTable(WMHashTable *table)
|
||||
|
||||
|
||||
|
||||
void*
|
||||
const void*
|
||||
WMHashGet(WMHashTable *table, const void *key)
|
||||
{
|
||||
unsigned h;
|
||||
@@ -218,8 +218,8 @@ WMHashGet(WMHashTable *table, const void *key)
|
||||
|
||||
|
||||
|
||||
void*
|
||||
WMHashInsert(WMHashTable *table, void *key, void *data)
|
||||
const void*
|
||||
WMHashInsert(WMHashTable *table, const void *key, const void *data)
|
||||
{
|
||||
unsigned h;
|
||||
HashItem *item;
|
||||
@@ -247,7 +247,7 @@ WMHashInsert(WMHashTable *table, void *key, void *data)
|
||||
}
|
||||
|
||||
if (replacing) {
|
||||
void *old;
|
||||
const void *old;
|
||||
|
||||
old = item->data;
|
||||
item->data = data;
|
||||
@@ -334,10 +334,10 @@ WMEnumerateHashTable(WMHashTable *table)
|
||||
|
||||
|
||||
|
||||
void*
|
||||
const void*
|
||||
WMNextHashEnumeratorItem(WMHashEnumerator *enumerator)
|
||||
{
|
||||
void *data = NULL;
|
||||
const void *data = NULL;
|
||||
|
||||
/* this assumes the table doesn't change between
|
||||
* WMEnumerateHashTable() and WMNextHashEnumeratorItem() calls */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
typedef struct W_Notification {
|
||||
char *name;
|
||||
const char *name;
|
||||
void *object;
|
||||
void *clientData;
|
||||
int refCount;
|
||||
@@ -18,7 +18,7 @@ typedef struct W_Notification {
|
||||
extern void W_FlushASAPNotificationQueue();
|
||||
|
||||
|
||||
char*
|
||||
const char*
|
||||
WMGetNotificationName(WMNotification *notification)
|
||||
{
|
||||
return notification->name;
|
||||
@@ -40,7 +40,7 @@ WMGetNotificationClientData(WMNotification *notification)
|
||||
|
||||
|
||||
WMNotification*
|
||||
WMCreateNotification(char *name, void *object, void *clientData)
|
||||
WMCreateNotification(const char *name, void *object, void *clientData)
|
||||
{
|
||||
Notification *nPtr;
|
||||
|
||||
@@ -82,7 +82,7 @@ typedef struct NotificationObserver {
|
||||
WMNotificationObserverAction *observerAction;
|
||||
void *observer;
|
||||
|
||||
char *name;
|
||||
const char *name;
|
||||
void *object;
|
||||
|
||||
struct NotificationObserver *prev; /* for tables */
|
||||
@@ -119,7 +119,7 @@ W_InitNotificationCenter(void)
|
||||
|
||||
void
|
||||
WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
void *observer, char *name, void *object)
|
||||
void *observer, const char *name, void *object)
|
||||
{
|
||||
NotificationObserver *oRec, *rec;
|
||||
|
||||
@@ -133,7 +133,8 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
|
||||
|
||||
/* 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 this is not the first action for the observer */
|
||||
@@ -151,14 +152,16 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
notificationCenter->nilList = oRec;
|
||||
} else if (!name) {
|
||||
/* any message coming from object */
|
||||
rec = WMHashInsert(notificationCenter->objectTable, object, oRec);
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable,
|
||||
object, oRec);
|
||||
oRec->next = rec;
|
||||
if (rec) {
|
||||
rec->prev = oRec;
|
||||
}
|
||||
} else {
|
||||
/* name && (object || !object) */
|
||||
rec = WMHashInsert(notificationCenter->nameTable, name, oRec);
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable,
|
||||
name, oRec);
|
||||
oRec->next = rec;
|
||||
if (rec) {
|
||||
rec->prev = oRec;
|
||||
@@ -175,7 +178,8 @@ WMPostNotification(WMNotification *notification)
|
||||
WMRetainNotification(notification);
|
||||
|
||||
/* 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) {
|
||||
tmp = orec->next;
|
||||
@@ -192,7 +196,8 @@ WMPostNotification(WMNotification *notification)
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
tmp = orec->next;
|
||||
@@ -226,7 +231,8 @@ WMRemoveNotificationObserver(void *observer)
|
||||
NotificationObserver *orec, *tmp, *rec;
|
||||
|
||||
/* 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
|
||||
@@ -244,7 +250,8 @@ WMRemoveNotificationObserver(void *observer)
|
||||
notificationCenter->nilList = orec->next;
|
||||
} else if (!orec->name) {
|
||||
/* any message coming from object */
|
||||
rec = WMHashGet(notificationCenter->objectTable, orec->object);
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
|
||||
orec->object);
|
||||
if (rec==orec) {
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
@@ -256,7 +263,8 @@ WMRemoveNotificationObserver(void *observer)
|
||||
}
|
||||
} else {
|
||||
/* name && (object || !object) */
|
||||
rec = WMHashGet(notificationCenter->nameTable, orec->name);
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
if (rec==orec) {
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
@@ -282,13 +290,13 @@ WMRemoveNotificationObserver(void *observer)
|
||||
|
||||
|
||||
void
|
||||
WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
||||
WMRemoveNotificationObserverWithName(void *observer, const char *name, void *object)
|
||||
{
|
||||
NotificationObserver *orec, *tmp, *rec;
|
||||
NotificationObserver *newList = NULL;
|
||||
|
||||
/* get the list of actions the observer is doing */
|
||||
orec = WMHashGet(notificationCenter->observerTable, observer);
|
||||
orec = (NotificationObserver*)WMHashGet(notificationCenter->observerTable, observer);
|
||||
|
||||
WMHashRemove(notificationCenter->observerTable, observer);
|
||||
|
||||
@@ -301,7 +309,7 @@ WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
||||
if (notificationCenter->nilList == orec)
|
||||
notificationCenter->nilList = orec->next;
|
||||
} else if (!name) {
|
||||
rec = WMHashGet(notificationCenter->objectTable, orec->object);
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object);
|
||||
if (rec==orec) {
|
||||
assert(rec->prev==NULL);
|
||||
/* replace table entry */
|
||||
@@ -314,7 +322,8 @@ WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rec = WMHashGet(notificationCenter->nameTable, orec->name);
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
if (rec==orec) {
|
||||
assert(rec->prev==NULL);
|
||||
/* replace table entry */
|
||||
@@ -359,7 +368,7 @@ WMRemoveNotificationObserverWithName(void *observer, char *name, void *object)
|
||||
|
||||
|
||||
void
|
||||
WMPostNotificationName(char *name, void *object, void *clientData)
|
||||
WMPostNotificationName(const char *name, void *object, void *clientData)
|
||||
{
|
||||
WMNotification *notification;
|
||||
|
||||
|
||||
50
WINGs/wbox.c
50
WINGs/wbox.c
@@ -10,6 +10,7 @@ typedef struct {
|
||||
int space;
|
||||
unsigned expand:1;
|
||||
unsigned fill:1;
|
||||
unsigned end:1;
|
||||
} SubviewItem;
|
||||
|
||||
|
||||
@@ -82,16 +83,22 @@ rearrange(WMBox *box)
|
||||
{
|
||||
int i;
|
||||
int x, y;
|
||||
int xe, ye;
|
||||
int w = 1, h = 1;
|
||||
int total;
|
||||
int expands = 0;
|
||||
|
||||
x = box->borderWidth;
|
||||
y = box->borderWidth;
|
||||
|
||||
if (box->horizontal) {
|
||||
ye = box->borderWidth;
|
||||
xe = WMWidgetWidth(box) - box->borderWidth;
|
||||
h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
} else {
|
||||
xe = box->borderWidth;
|
||||
ye = WMWidgetHeight(box) - box->borderWidth;
|
||||
w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
}
|
||||
@@ -118,12 +125,23 @@ rearrange(WMBox *box)
|
||||
if (box->subviews[i].expand)
|
||||
h += total/expands;
|
||||
}
|
||||
W_MoveView(box->subviews[i].view, x, y);
|
||||
if (!box->subviews[i].end) {
|
||||
W_MoveView(box->subviews[i].view, x, y);
|
||||
}
|
||||
W_ResizeView(box->subviews[i].view, w, h);
|
||||
if (box->horizontal) {
|
||||
x += w + box->subviews[i].space;
|
||||
if (box->subviews[i].end)
|
||||
xe -= w + box->subviews[i].space;
|
||||
else
|
||||
x += w + box->subviews[i].space;
|
||||
} else {
|
||||
y += h + box->subviews[i].space;
|
||||
if (box->subviews[i].end)
|
||||
ye -= h + box->subviews[i].space;
|
||||
else
|
||||
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].fill = fill;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -412,11 +412,11 @@ WMSetButtonSelected(WMButton *bPtr, int isSelected)
|
||||
{
|
||||
bPtr->flags.selected = isSelected;
|
||||
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
if (bPtr->groupIndex > 0)
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -485,15 +485,15 @@ WMPerformButtonClick(WMButton *bPtr)
|
||||
XFlush(WMScreenDisplay(WMWidgetScreen(bPtr)));
|
||||
wusleep(20000);
|
||||
}
|
||||
|
||||
bPtr->flags.pushed = 0;
|
||||
|
||||
if (bPtr->groupIndex>0) {
|
||||
if (bPtr->groupIndex > 0) {
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
|
||||
bPtr->flags.pushed = 0;
|
||||
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintButton(bPtr);
|
||||
@@ -728,17 +728,14 @@ handleActionEvents(XEvent *event, void *data)
|
||||
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button == Button1) {
|
||||
bPtr->flags.prevSelected = bPtr->flags.selected;
|
||||
bPtr->flags.wasPushed = 0;
|
||||
bPtr->flags.pushed = 1;
|
||||
if (bPtr->groupIndex>0) {
|
||||
if (!bPtr->flags.selected)
|
||||
doclick = 1;
|
||||
bPtr->flags.pushed = 1;
|
||||
bPtr->flags.selected = 1;
|
||||
dopaint = 1;
|
||||
break;
|
||||
}
|
||||
bPtr->flags.wasPushed = 0;
|
||||
bPtr->flags.pushed = 1;
|
||||
bPtr->flags.prevSelected = bPtr->flags.selected;
|
||||
bPtr->flags.selected = !bPtr->flags.selected;
|
||||
dopaint = 1;
|
||||
|
||||
@@ -752,7 +749,8 @@ handleActionEvents(XEvent *event, void *data)
|
||||
case ButtonRelease:
|
||||
if (event->xbutton.button == Button1) {
|
||||
if (bPtr->flags.pushed) {
|
||||
if (bPtr->groupIndex==0)
|
||||
if (bPtr->groupIndex==0 ||
|
||||
bPtr->flags.selected && bPtr->groupIndex > 0)
|
||||
doclick = 1;
|
||||
dopaint = 1;
|
||||
if (bPtr->flags.springLoaded) {
|
||||
@@ -772,10 +770,10 @@ handleActionEvents(XEvent *event, void *data)
|
||||
paintButton(bPtr);
|
||||
|
||||
if (doclick) {
|
||||
if (bPtr->flags.selected && bPtr->groupIndex>0) {
|
||||
if (bPtr->flags.selected && bPtr->groupIndex > 0) {
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
}
|
||||
|
||||
@@ -531,6 +531,9 @@ popUpMenu(PopUpButton *bPtr)
|
||||
Window dummyW;
|
||||
int x, y;
|
||||
|
||||
if (!bPtr->flags.enabled)
|
||||
return;
|
||||
|
||||
if (!bPtr->menuView->flags.realized) {
|
||||
W_RealizeView(bPtr->menuView);
|
||||
resizeMenu(bPtr);
|
||||
@@ -553,6 +556,9 @@ popUpMenu(PopUpButton *bPtr)
|
||||
makeMenuPixmap(bPtr));
|
||||
XClearWindow(scr->display, bPtr->menuView->window);
|
||||
|
||||
if (W_VIEW_WIDTH(bPtr->menuView) != W_VIEW_WIDTH(bPtr->view))
|
||||
resizeMenu(bPtr);
|
||||
|
||||
W_MapView(bPtr->menuView);
|
||||
|
||||
bPtr->highlightedItem = 0;
|
||||
|
||||
@@ -36,7 +36,7 @@ static void paintScrollView(ScrollView *sPtr);
|
||||
static void handleEvents(XEvent *event, void *data);
|
||||
static void handleViewportEvents(XEvent *event, void *data);
|
||||
static void resizeScrollView();
|
||||
|
||||
static void updateScrollerProportion();
|
||||
|
||||
W_ViewDelegate _ScrollViewViewDelegate = {
|
||||
NULL,
|
||||
@@ -64,21 +64,16 @@ WMCreateScrollView(WMWidget *parent)
|
||||
return NULL;
|
||||
}
|
||||
sPtr->viewport = W_CreateView(sPtr->view);
|
||||
if (!sPtr->view) {
|
||||
if (!sPtr->viewport) {
|
||||
W_DestroyView(sPtr->view);
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
}
|
||||
sPtr->view->self = sPtr;
|
||||
|
||||
sPtr->viewport->self = sPtr;
|
||||
|
||||
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;
|
||||
|
||||
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
|
||||
reorganizeInterior(WMScrollView *sPtr)
|
||||
@@ -122,7 +156,7 @@ reorganizeInterior(WMScrollView *sPtr)
|
||||
}
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
int h = W_VIEW(sPtr->hScroller)->size.height;
|
||||
int h = 20;
|
||||
|
||||
ch -= h;
|
||||
|
||||
@@ -144,7 +178,7 @@ reorganizeInterior(WMScrollView *sPtr)
|
||||
}
|
||||
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
int w = W_VIEW(sPtr->vScroller)->size.width;
|
||||
int w = 20;
|
||||
cw -= w;
|
||||
cx += w;
|
||||
hx += w - 1;
|
||||
@@ -178,6 +212,8 @@ reorganizeInterior(WMScrollView *sPtr)
|
||||
WMResizeWidget(sPtr->vScroller, 20, vh);
|
||||
WMMoveWidget(sPtr->vScroller, vx, vy);
|
||||
}
|
||||
|
||||
applyScrollerValues(sPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +221,7 @@ static void
|
||||
resizeScrollView(W_ViewDelegate *self, WMView *view)
|
||||
{
|
||||
reorganizeInterior(view->self);
|
||||
updateScrollerProportion(view->self);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,11 +246,11 @@ WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width,
|
||||
}
|
||||
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
w -= W_VIEW(sPtr->hScroller)->size.width;
|
||||
width -= W_VIEW(sPtr->hScroller)->size.width;
|
||||
WMResizeWidget(sPtr->vScroller, 20, h);
|
||||
}
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
h -= W_VIEW(sPtr->hScroller)->size.height;
|
||||
height -= W_VIEW(sPtr->hScroller)->size.height;
|
||||
WMResizeWidget(sPtr->hScroller, w, 20);
|
||||
WMMoveWidget(sPtr->hScroller, x, h);
|
||||
}
|
||||
@@ -246,13 +283,38 @@ WMRect
|
||||
WMGetScrollViewVisibleRect(WMScrollView *sPtr)
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
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
|
||||
doScrolling(WMWidget *self, void *data)
|
||||
{
|
||||
@@ -473,6 +535,7 @@ WMSetScrollViewRelief(WMScrollView *sPtr, WMReliefType type)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
paintScrollView(ScrollView *sPtr)
|
||||
{
|
||||
|
||||
@@ -746,11 +746,14 @@ WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview)
|
||||
WMViewMoveDidChangeNotification,
|
||||
subview);
|
||||
*/
|
||||
if (wasMapped)
|
||||
if (wasMapped) {
|
||||
W_MapView(subview);
|
||||
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
} else {
|
||||
handleViewResized(sPtr, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -844,10 +847,11 @@ WMSetSplitViewVertical(WMSplitView *sPtr, Bool flag)
|
||||
|
||||
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);
|
||||
else
|
||||
/* else
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
291
WINGs/wtabview.c
291
WINGs/wtabview.c
@@ -22,7 +22,6 @@ typedef struct W_TabView {
|
||||
|
||||
WMTabViewDelegate *delegate;
|
||||
|
||||
short tabWidth;
|
||||
short tabHeight;
|
||||
|
||||
struct {
|
||||
@@ -32,6 +31,8 @@ typedef struct W_TabView {
|
||||
|
||||
unsigned tabbed:1;
|
||||
unsigned dontFitAll:1;
|
||||
unsigned bordered:1;
|
||||
unsigned uniformTabs:1;
|
||||
} flags;
|
||||
} TabView;
|
||||
|
||||
@@ -44,7 +45,7 @@ typedef struct W_TabView {
|
||||
#define DEFAULT_HEIGHT 40
|
||||
|
||||
#define NORMAL_SIDE_OFFSET 8
|
||||
#define BUTTONED_SIDE_OFFSET 20
|
||||
#define BUTTONED_SIDE_OFFSET 15
|
||||
|
||||
|
||||
static void destroyTabView(TabView *tPtr);
|
||||
@@ -61,8 +62,13 @@ static void W_MapTabViewItem(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*);
|
||||
|
||||
@@ -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
|
||||
@@ -100,21 +152,21 @@ handleEvents(XEvent *event, void *data)
|
||||
WMSelectTabViewItem(tPtr, item);
|
||||
} else if (tPtr->flags.dontFitAll) {
|
||||
int redraw;
|
||||
int lastVisible = tPtr->firstVisible+tPtr->visibleTabs-1;
|
||||
|
||||
if (event->xbutton.x < BUTTONED_SIDE_OFFSET) {
|
||||
if (tPtr->firstVisible > 0) {
|
||||
redraw = 1;
|
||||
tPtr->firstVisible--;
|
||||
}
|
||||
} else if (event->xbutton.x - BUTTONED_SIDE_OFFSET
|
||||
> tPtr->visibleTabs*(tPtr->tabWidth-10)) {
|
||||
} else if (event->xbutton.x > positionOfTab(tPtr,lastVisible)){
|
||||
|
||||
if (tPtr->firstVisible + tPtr->visibleTabs
|
||||
< tPtr->itemCount) {
|
||||
if (lastVisible < tPtr->itemCount-1) {
|
||||
redraw = 1;
|
||||
tPtr->firstVisible++;
|
||||
}
|
||||
}
|
||||
|
||||
tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible);
|
||||
if (redraw) {
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
@@ -153,6 +205,10 @@ WMCreateTabView(WMWidget *parent)
|
||||
tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, False);
|
||||
|
||||
tPtr->font = WMRetainFont(scr->normalFont);
|
||||
|
||||
tPtr->flags.type = WTTopTabsBevelBorder;
|
||||
tPtr->flags.bordered = 1;
|
||||
tPtr->flags.uniformTabs = 0;
|
||||
|
||||
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|
||||
|ButtonPressMask, handleEvents, tPtr);
|
||||
@@ -217,8 +273,8 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
||||
}
|
||||
|
||||
if (index < tPtr->itemCount) {
|
||||
memmove(&tPtr->items[index + 1], &tPtr->items[index],
|
||||
tPtr->itemCount - index);
|
||||
memmove(tPtr->items + index + 1, tPtr->items + index,
|
||||
(tPtr->itemCount - index) * sizeof(WMTabViewItem*));
|
||||
}
|
||||
|
||||
tPtr->items[index] = item;
|
||||
@@ -231,17 +287,28 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
||||
|
||||
W_UnmapTabViewItem(item);
|
||||
|
||||
W_ReparentView(W_TabViewItemView(item), tPtr->view, 1,
|
||||
tPtr->tabHeight + 1);
|
||||
if (tPtr->flags.bordered) {
|
||||
W_ReparentView(W_TabViewItemView(item), tPtr->view, 1,
|
||||
tPtr->tabHeight + 1);
|
||||
|
||||
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 3,
|
||||
tPtr->view->size.height - tPtr->tabHeight - 3);
|
||||
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width - 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) {
|
||||
W_MapTabViewItem(item);
|
||||
}
|
||||
if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems)
|
||||
(*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;
|
||||
|
||||
if (tPtr->flags.dontFitAll) {
|
||||
offset = BUTTONED_SIDE_OFFSET;
|
||||
|
||||
i = tPtr->selectedItem - tPtr->firstVisible;
|
||||
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)) {
|
||||
return tPtr->items[tPtr->selectedItem];
|
||||
}
|
||||
} else {
|
||||
offset = NORMAL_SIDE_OFFSET;
|
||||
|
||||
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)) {
|
||||
return tPtr->items[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (isInside(offset + (tPtr->tabWidth-10)*i, 0, tPtr->tabWidth,
|
||||
for (i = first; i < first + count; i++) {
|
||||
int pos;
|
||||
|
||||
pos = positionOfTab(tPtr, i);
|
||||
if (isInside(pos, 0, W_TabViewItemTabWidth(tPtr->items[i]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[i+first];
|
||||
return tPtr->items[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -336,6 +404,18 @@ void
|
||||
WMSetTabViewType(WMTabView *tPtr, WMTabViewType 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
|
||||
@@ -429,6 +509,7 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
recalcTabWidth(TabView *tPtr)
|
||||
{
|
||||
@@ -436,25 +517,52 @@ recalcTabWidth(TabView *tPtr)
|
||||
int twidth = W_VIEW(tPtr)->size.width;
|
||||
int width;
|
||||
|
||||
tPtr->tabWidth = 0;
|
||||
for (i = 0; i < tPtr->itemCount; i++) {
|
||||
char *str = WMGetTabViewItemLabel(tPtr->items[i]);
|
||||
if (tPtr->flags.uniformTabs) {
|
||||
int tabWidth;
|
||||
|
||||
tabWidth = 0;
|
||||
|
||||
if (str) {
|
||||
width = WMWidthOfString(tPtr->font, str, strlen(str));
|
||||
if (width > tPtr->tabWidth)
|
||||
tPtr->tabWidth = width;
|
||||
for (i = 0; i < tPtr->itemCount; i++) {
|
||||
char *str = WMGetTabViewItemLabel(tPtr->items[i]);
|
||||
|
||||
if (str) {
|
||||
width = WMWidthOfString(tPtr->font, str, strlen(str));
|
||||
if (width > tabWidth)
|
||||
tabWidth = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
tPtr->tabWidth += 30;
|
||||
if ((tPtr->tabWidth + 2) * tPtr->itemCount > twidth - 2*NORMAL_SIDE_OFFSET) {
|
||||
tPtr->flags.dontFitAll = 1;
|
||||
|
||||
tabWidth = tabWidth + 30;
|
||||
|
||||
for (i = 0; i < tPtr->itemCount; i++)
|
||||
W_SetTabViewItemTabWidth(tPtr->items[i], tabWidth);
|
||||
|
||||
tPtr->firstVisible = 0;
|
||||
tPtr->visibleTabs = (twidth - 2*BUTTONED_SIDE_OFFSET) / (tPtr->tabWidth-10);
|
||||
tPtr->visibleTabs = countVisibleTabs(tPtr, -1);
|
||||
if (tPtr->visibleTabs < tPtr->itemCount)
|
||||
tPtr->flags.dontFitAll = 1;
|
||||
else
|
||||
tPtr->flags.dontFitAll = 0;
|
||||
} else {
|
||||
tPtr->flags.dontFitAll = 0;
|
||||
tPtr->firstVisible = 0;
|
||||
tPtr->visibleTabs = tPtr->itemCount;
|
||||
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->firstVisible = 0;
|
||||
tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible);
|
||||
} else {
|
||||
tPtr->flags.dontFitAll = 0;
|
||||
tPtr->firstVisible = 0;
|
||||
tPtr->visibleTabs = tPtr->itemCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,27 +660,27 @@ paintTabView(TabView *tPtr)
|
||||
Display *dpy = scr->display;
|
||||
GC white = WMColorGC(scr->white);
|
||||
int i;
|
||||
WMRect rect;
|
||||
|
||||
if (tPtr->flags.type == WTTopTabsBevelBorder) {
|
||||
int count = tPtr->visibleTabs;
|
||||
int first = tPtr->firstVisible;
|
||||
int offs;
|
||||
int moreAtLeft;
|
||||
int moreAtRight;
|
||||
int selectedIsVisible;
|
||||
int tx, ty;
|
||||
int twidth, theight;
|
||||
|
||||
ty = 2;
|
||||
theight = tPtr->tabHeight;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor),
|
||||
0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight);
|
||||
|
||||
rect.pos.y = 2;
|
||||
if (tPtr->flags.dontFitAll) {
|
||||
rect.pos.x = 15 + BUTTONED_SIDE_OFFSET;
|
||||
offs = BUTTONED_SIDE_OFFSET;
|
||||
moreAtLeft = first > 0;
|
||||
moreAtRight = (first + count) < tPtr->itemCount;
|
||||
if (tPtr->selectedItem >= first
|
||||
@@ -581,44 +689,55 @@ paintTabView(TabView *tPtr)
|
||||
else
|
||||
selectedIsVisible = 0;
|
||||
} else {
|
||||
rect.pos.x = 15 + NORMAL_SIDE_OFFSET;
|
||||
offs = NORMAL_SIDE_OFFSET;
|
||||
moreAtLeft = 0;
|
||||
moreAtRight = 0;
|
||||
selectedIsVisible = 1;
|
||||
}
|
||||
rect.size.width = tPtr->tabWidth;
|
||||
rect.size.height = tPtr->tabHeight;
|
||||
|
||||
for (i = count - (moreAtRight ? 0 : 1);
|
||||
i >= (moreAtLeft ? -1 : 0); i--) {
|
||||
if (!selectedIsVisible || i != (tPtr->selectedItem-first)) {
|
||||
drawTab(tPtr, buffer, offs + (rect.size.width-10)*i, 0,
|
||||
rect.size.width, rect.size.height, False);
|
||||
if (moreAtRight) {
|
||||
drawTab(tPtr, buffer, positionOfTab(tPtr, first+count), 0,
|
||||
W_VIEW_WIDTH(tPtr->view), theight, 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) {
|
||||
drawTab(tPtr, buffer,
|
||||
offs + (rect.size.width-10) * (tPtr->selectedItem - first),
|
||||
0, rect.size.width, rect.size.height, True);
|
||||
int idx = tPtr->selectedItem;
|
||||
|
||||
XDrawLine(dpy, buffer, white, 0, tPtr->tabHeight - 1,
|
||||
offs, tPtr->tabHeight - 1);
|
||||
drawTab(tPtr, buffer, positionOfTab(tPtr, idx),
|
||||
0, W_TabViewItemTabWidth(tPtr->items[idx]),
|
||||
theight, True);
|
||||
|
||||
XDrawLine(dpy, buffer, white, 0, theight - 1,
|
||||
positionOfTab(tPtr, idx), theight - 1);
|
||||
|
||||
XDrawLine(dpy, buffer, white,
|
||||
offs + 10 + (rect.size.width-10) * count,
|
||||
tPtr->tabHeight - 1, W_VIEW(tPtr)->size.width - 1,
|
||||
positionOfTab(tPtr, idx) + W_TabViewItemTabWidth(tPtr->items[idx]),
|
||||
tPtr->tabHeight - 1, W_VIEW_WIDTH(tPtr->view) - 1,
|
||||
tPtr->tabHeight - 1);
|
||||
} else {
|
||||
XDrawLine(dpy, buffer, white, 0, tPtr->tabHeight - 1,
|
||||
W_VIEW(tPtr)->size.width, tPtr->tabHeight - 1);
|
||||
XDrawLine(dpy, buffer, white, 0, theight - 1,
|
||||
W_VIEW_WIDTH(tPtr->view), theight - 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
WMRect rect;
|
||||
|
||||
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);
|
||||
|
||||
rect.pos.x += rect.size.width - 10;
|
||||
}
|
||||
|
||||
if (moreAtLeft) {
|
||||
@@ -629,17 +748,16 @@ paintTabView(TabView *tPtr)
|
||||
if (moreAtRight) {
|
||||
int x;
|
||||
|
||||
x = BUTTONED_SIDE_OFFSET - 5 + tPtr->visibleTabs * (tPtr->tabWidth - 10);
|
||||
|
||||
x = x + (W_VIEW(tPtr)->size.width - x)/2;
|
||||
|
||||
x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs);
|
||||
|
||||
x = x + (W_VIEW_WIDTH(tPtr->view) - x)/2;
|
||||
paintDot(tPtr, buffer, x + 5, 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,
|
||||
W_VIEW(tPtr)->size.width, tPtr->tabHeight, 0, 0);
|
||||
W_VIEW_WIDTH(tPtr->view), theight, 0, 0);
|
||||
|
||||
XFreePixmap(dpy, buffer);
|
||||
}
|
||||
@@ -671,13 +789,16 @@ rearrange(TabView *tPtr)
|
||||
{
|
||||
int i;
|
||||
int width, height;
|
||||
int bordered = tPtr->flags.bordered;
|
||||
|
||||
recalcTabWidth(tPtr);
|
||||
|
||||
width = tPtr->view->size.width - 3;
|
||||
height = tPtr->view->size.height - tPtr->tabHeight - 3;
|
||||
|
||||
width = tPtr->view->size.width - (bordered ? 3 : 0);
|
||||
height = tPtr->view->size.height - tPtr->tabHeight - (bordered ? 3 : 0);
|
||||
|
||||
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);
|
||||
}
|
||||
if (W_VIEW_MAPPED(tPtr->view) && W_VIEW_REALIZED(tPtr->view))
|
||||
@@ -720,6 +841,7 @@ typedef struct W_TabViewItem {
|
||||
|
||||
char *label;
|
||||
|
||||
short tabWidth;
|
||||
int identifier;
|
||||
|
||||
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*
|
||||
WMCreateTabViewItemWithIdentifier(int identifier)
|
||||
{
|
||||
@@ -833,7 +969,10 @@ WMSetTabViewItemLabel(WMTabViewItem *item, char *label)
|
||||
if (item->label)
|
||||
wfree(item->label);
|
||||
|
||||
item->label = wstrdup(label);
|
||||
if (label)
|
||||
item->label = wstrdup(label);
|
||||
else
|
||||
item->label = NULL;
|
||||
|
||||
if (item->tabView)
|
||||
recalcTabWidth(item->tabView);
|
||||
|
||||
@@ -1730,6 +1730,9 @@ y = tPtr->docHeight+ss-sd;
|
||||
|
||||
if(items && itemsSize > 0)
|
||||
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
|
||||
|| !tPtr->currentTextBlock) {
|
||||
printf("cannot remove non existent TextBlock!\b");
|
||||
/* printf("cannot remove non existent TextBlock!\n"); */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,6 +545,8 @@ W_RedisplayView(W_View *view)
|
||||
ev.xexpose.window = view->window;
|
||||
ev.xexpose.count = 0;
|
||||
|
||||
ev.xexpose.serial = 0;
|
||||
|
||||
WMHandleEvent(&ev);
|
||||
}
|
||||
|
||||
|
||||
@@ -665,11 +665,20 @@ handleEvents(XEvent *event, void *clientData)
|
||||
}
|
||||
}
|
||||
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:
|
||||
WMUnmapWidget(win);
|
||||
break;
|
||||
|
||||
*
|
||||
case MapNotify:
|
||||
WMMapWidget(win);
|
||||
break;
|
||||
|
||||
*/
|
||||
case DestroyNotify:
|
||||
destroyWindow(win);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user