mirror of
https://github.com/gryf/wmaker.git
synced 2026-10-09 11:12:29 +02:00
changed indentation to use spaces only
This commit is contained in:
1 parent
5912898b06
commit
6830b05716
240 files changed
+35949
-35771
No files matched your search
@@ -8,7 +8,7 @@
|
||||
void showSelectedColor(void *self, void *cdata)
|
||||
{
|
||||
WMColorPanel *panel= (WMColorPanel*)self;
|
||||
|
||||
|
||||
printf("Selected Color: %s\n", WMGetColorRGBDescription(WMGetColorPanelColor(panel)));
|
||||
}
|
||||
|
||||
@@ -17,26 +17,26 @@ int main(int argc, char **argv)
|
||||
{
|
||||
Display *dpy;
|
||||
WMScreen *scr;
|
||||
|
||||
|
||||
WMInitializeApplication("wmcolorpick", &argc, argv);
|
||||
|
||||
dpy = XOpenDisplay("");
|
||||
if (!dpy) {
|
||||
printf("could not open display\n");
|
||||
exit(1);
|
||||
printf("could not open display\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
scr = WMCreateScreen(dpy, DefaultScreen(dpy));
|
||||
|
||||
{
|
||||
WMColorPanel *panel= WMGetColorPanel(scr);
|
||||
|
||||
|
||||
WMSetColorPanelAction(panel, showSelectedColor, NULL);
|
||||
|
||||
|
||||
WMShowColorPanel(panel);
|
||||
}
|
||||
|
||||
|
||||
WMScreenMainLoop(scr);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* WINGs connect.c: example how to create a network client using WMConnection
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1999-2003 Dan Pascu
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
+21
-21
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* WINGs demo: font lister
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1998-2003 Alfredo K. Kojima
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
@@ -64,10 +64,10 @@ main(int argc, char **argv)
|
||||
|
||||
dpy = XOpenDisplay("");
|
||||
if (!dpy) {
|
||||
wfatal("cant open display");
|
||||
exit(0);
|
||||
wfatal("cant open display");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
scr = WMCreateSimpleApplicationScreen(dpy);
|
||||
|
||||
win = WMCreateWindow(scr, "main");
|
||||
@@ -80,25 +80,25 @@ main(int argc, char **argv)
|
||||
|
||||
c = 0;
|
||||
for (y=0; y<8; y++) {
|
||||
for (x=0; x<32; x++, c++) {
|
||||
lab = WMCreateCustomButton(win, WBBStateLightMask);
|
||||
WMResizeWidget(lab, 20, 20);
|
||||
WMMoveWidget(lab, 10+x*20, 30+y*20);
|
||||
sprintf(buf, "%c", c);
|
||||
WMSetButtonText(lab, buf);
|
||||
WMSetButtonAction(lab, show, pos);
|
||||
WMHangData(lab, (void*)c);
|
||||
if (c>0) {
|
||||
WMGroupButtons(l0, lab);
|
||||
} else {
|
||||
l0 = lab;
|
||||
}
|
||||
}
|
||||
for (x=0; x<32; x++, c++) {
|
||||
lab = WMCreateCustomButton(win, WBBStateLightMask);
|
||||
WMResizeWidget(lab, 20, 20);
|
||||
WMMoveWidget(lab, 10+x*20, 30+y*20);
|
||||
sprintf(buf, "%c", c);
|
||||
WMSetButtonText(lab, buf);
|
||||
WMSetButtonAction(lab, show, pos);
|
||||
WMHangData(lab, (void*)c);
|
||||
if (c>0) {
|
||||
WMGroupButtons(l0, lab);
|
||||
} else {
|
||||
l0 = lab;
|
||||
}
|
||||
}
|
||||
}
|
||||
WMRealizeWidget(win);
|
||||
WMMapSubwidgets(win);
|
||||
WMMapWidget(win);
|
||||
WMScreenMainLoop(scr);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
+118
-117
@@ -25,12 +25,12 @@ Bool
|
||||
CheckWin(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < Size*Size-1; i++) {
|
||||
if (Map[i] != i)
|
||||
return False;
|
||||
if (Map[i] != i)
|
||||
return False;
|
||||
}
|
||||
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
@@ -46,37 +46,37 @@ Bool
|
||||
SlideButton(int button)
|
||||
{
|
||||
int x=0, y=0, done = 0;
|
||||
|
||||
|
||||
/* locate the button */
|
||||
for (y = 0; y < Size; y++) {
|
||||
for (x = 0; x < Size; x++) {
|
||||
if (MAP(x,y) == button) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (done)
|
||||
break;
|
||||
for (x = 0; x < Size; x++) {
|
||||
if (MAP(x,y) == button) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (done)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (x > 0 && MAP(x-1, y) < 0) {
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x-1, y);
|
||||
MAP(x-1,y) = button;
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x-1, y);
|
||||
MAP(x-1,y) = button;
|
||||
} else if (x < Size-1 && MAP(x+1, y) < 0) {
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x+1, y);
|
||||
MAP(x+1,y) = button;
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x+1, y);
|
||||
MAP(x+1,y) = button;
|
||||
} else if (y > 0 && MAP(x, y-1) < 0) {
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x, y-1);
|
||||
MAP(x,y-1) = button;
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x, y-1);
|
||||
MAP(x,y-1) = button;
|
||||
} else if (y < Size-1 && MAP(x, y+1) < 0) {
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x, y+1);
|
||||
MAP(x,y+1) = button;
|
||||
MAP(x,y) = -1;
|
||||
MoveButton(button, x, y+1);
|
||||
MAP(x,y+1) = button;
|
||||
} else {
|
||||
return False;
|
||||
return False;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
@@ -87,46 +87,46 @@ SlideButton(int button)
|
||||
void ResetGame(void)
|
||||
{
|
||||
int i, x, y, ox, oy;
|
||||
|
||||
|
||||
|
||||
|
||||
MoveCount = 0;
|
||||
|
||||
|
||||
for (i = 0; i < Size*Size-1; i++) {
|
||||
Map[i] = i;
|
||||
Map[i] = i;
|
||||
}
|
||||
Map[i] = -1;
|
||||
ox = x = Size-1;
|
||||
oy = y = Size-1;
|
||||
for (i = 0; i < 1000; i++) {
|
||||
int ok;
|
||||
ok = 1;
|
||||
switch (rand()%4) {
|
||||
case 0:
|
||||
if (x > 0) x--; else ok = 0;
|
||||
break;
|
||||
case 2:
|
||||
if (x < Size-1) x++; else ok = 0;
|
||||
break;
|
||||
case 1:
|
||||
if (y > 0) y--; else ok = 0;
|
||||
break;
|
||||
case 3:
|
||||
if (y < Size-1) y++; else ok = 0;
|
||||
break;
|
||||
}
|
||||
if (ok) {
|
||||
MoveButton(MAP(x,y), ox, oy);
|
||||
int ok;
|
||||
ok = 1;
|
||||
switch (rand()%4) {
|
||||
case 0:
|
||||
if (x > 0) x--; else ok = 0;
|
||||
break;
|
||||
case 2:
|
||||
if (x < Size-1) x++; else ok = 0;
|
||||
break;
|
||||
case 1:
|
||||
if (y > 0) y--; else ok = 0;
|
||||
break;
|
||||
case 3:
|
||||
if (y < Size-1) y++; else ok = 0;
|
||||
break;
|
||||
}
|
||||
if (ok) {
|
||||
MoveButton(MAP(x,y), ox, oy);
|
||||
|
||||
SWAP(MAP(ox, oy), MAP(x, y));
|
||||
|
||||
while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) {
|
||||
XEvent ev;
|
||||
WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev);
|
||||
WMHandleEvent(&ev);
|
||||
}
|
||||
ox = x;
|
||||
oy = y;
|
||||
}
|
||||
SWAP(MAP(ox, oy), MAP(x, y));
|
||||
|
||||
while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) {
|
||||
XEvent ev;
|
||||
WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev);
|
||||
WMHandleEvent(&ev);
|
||||
}
|
||||
ox = x;
|
||||
oy = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,18 +136,18 @@ void buttonClick(WMWidget *w, void *ptr)
|
||||
char buffer[300];
|
||||
|
||||
if (SlideButton((int)ptr)) {
|
||||
MoveCount++;
|
||||
MoveCount++;
|
||||
|
||||
if (CheckWin()) {
|
||||
sprintf(buffer, "You finished the game in %i moves.", MoveCount);
|
||||
if (CheckWin()) {
|
||||
sprintf(buffer, "You finished the game in %i moves.", MoveCount);
|
||||
|
||||
if (WMRunAlertPanel(WMWidgetScreen(w), win, "You Won!", buffer,
|
||||
"Wee!", "Gah! Lemme retry!", NULL) == WAPRDefault) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ResetGame();
|
||||
}
|
||||
if (WMRunAlertPanel(WMWidgetScreen(w), win, "You Won!", buffer,
|
||||
"Wee!", "Gah! Lemme retry!", NULL) == WAPRDefault) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
ResetGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,17 +156,17 @@ static void resizeObserver(void *self, WMNotification *notif)
|
||||
{
|
||||
WMSize size = WMGetViewSize(WMWidgetView(win));
|
||||
int x, y;
|
||||
|
||||
|
||||
WinSize = size.width;
|
||||
for (y = 0; y < Size; y++) {
|
||||
for (x = 0; x < Size; x++) {
|
||||
if (MAP(x,y) >= 0) {
|
||||
WMResizeWidget(Button[(int)MAP(x,y)],
|
||||
WinSize/Size, WinSize/Size);
|
||||
WMMoveWidget(Button[(int)MAP(x,y)],
|
||||
x*(WinSize/Size), y*(WinSize/Size));
|
||||
}
|
||||
}
|
||||
for (x = 0; x < Size; x++) {
|
||||
if (MAP(x,y) >= 0) {
|
||||
WMResizeWidget(Button[(int)MAP(x,y)],
|
||||
WinSize/Size, WinSize/Size);
|
||||
WMMoveWidget(Button[(int)MAP(x,y)],
|
||||
x*(WinSize/Size), y*(WinSize/Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -177,18 +177,18 @@ int main(int argc, char **argv)
|
||||
Display *dpy;
|
||||
WMScreen *scr;
|
||||
int x, y, i;
|
||||
|
||||
|
||||
WMInitializeApplication("Puzzle", &argc, argv);
|
||||
|
||||
|
||||
|
||||
dpy = XOpenDisplay("");
|
||||
if (!dpy) {
|
||||
printf("could not open display\n");
|
||||
exit(1);
|
||||
printf("could not open display\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
scr = WMCreateScreen(dpy, DefaultScreen(dpy));
|
||||
|
||||
|
||||
win = WMCreateWindow(scr, "puzzle");
|
||||
WMResizeWidget(win, WinSize, WinSize);
|
||||
WMSetWindowTitle(win, "zuPzel");
|
||||
@@ -197,48 +197,49 @@ int main(int argc, char **argv)
|
||||
WMSetWindowResizeIncrements(win, Size, Size);
|
||||
WMSetViewNotifySizeChanges(WMWidgetView(win), True);
|
||||
WMAddNotificationObserver(resizeObserver, NULL,
|
||||
WMViewSizeDidChangeNotification,
|
||||
WMWidgetView(win));
|
||||
|
||||
|
||||
|
||||
WMViewSizeDidChangeNotification,
|
||||
WMWidgetView(win));
|
||||
|
||||
|
||||
|
||||
for (i = y = 0; y < Size && i < Size*Size-1; y++) {
|
||||
for (x = 0; x < Size && i < Size*Size-1; x++) {
|
||||
char buf[32];
|
||||
WMColor *color;
|
||||
RColor col;
|
||||
RHSVColor hsv;
|
||||
|
||||
hsv.hue = i*360/(Size*Size-1);
|
||||
hsv.saturation = 120;
|
||||
hsv.value = 200;
|
||||
|
||||
RHSVtoRGB(&hsv, &col);
|
||||
for (x = 0; x < Size && i < Size*Size-1; x++) {
|
||||
char buf[32];
|
||||
WMColor *color;
|
||||
RColor col;
|
||||
RHSVColor hsv;
|
||||
|
||||
color = WMCreateRGBColor(scr, col.red<<8, col.green<<8,
|
||||
col.blue<<8, False);
|
||||
hsv.hue = i*360/(Size*Size-1);
|
||||
hsv.saturation = 120;
|
||||
hsv.value = 200;
|
||||
|
||||
MAP(x,y) = i;
|
||||
Button[i] = WMCreateButton(win, WBTMomentaryLight);
|
||||
WMSetWidgetBackgroundColor(Button[i], color);
|
||||
WMReleaseColor(color);
|
||||
WMSetButtonAction(Button[i], buttonClick, (void*)i);
|
||||
WMResizeWidget(Button[i], WinSize/Size, WinSize/Size);
|
||||
WMMoveWidget(Button[i], x*(WinSize/Size), y*(WinSize/Size));
|
||||
sprintf(buf, "%i", i+1);
|
||||
WMSetButtonText(Button[i], buf);
|
||||
WMSetButtonTextAlignment(Button[i], WACenter);
|
||||
i++;
|
||||
}
|
||||
RHSVtoRGB(&hsv, &col);
|
||||
|
||||
color = WMCreateRGBColor(scr, col.red<<8, col.green<<8,
|
||||
col.blue<<8, False);
|
||||
|
||||
MAP(x,y) = i;
|
||||
Button[i] = WMCreateButton(win, WBTMomentaryLight);
|
||||
WMSetWidgetBackgroundColor(Button[i], color);
|
||||
WMReleaseColor(color);
|
||||
WMSetButtonAction(Button[i], buttonClick, (void*)i);
|
||||
WMResizeWidget(Button[i], WinSize/Size, WinSize/Size);
|
||||
WMMoveWidget(Button[i], x*(WinSize/Size), y*(WinSize/Size));
|
||||
sprintf(buf, "%i", i+1);
|
||||
WMSetButtonText(Button[i], buf);
|
||||
WMSetButtonTextAlignment(Button[i], WACenter);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WMMapSubwidgets(win);
|
||||
WMMapWidget(win);
|
||||
WMRealizeWidget(win);
|
||||
|
||||
|
||||
ResetGame();
|
||||
|
||||
WMScreenMainLoop(scr);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+38
-33
@@ -12,61 +12,65 @@ static int col2[20];
|
||||
|
||||
static char *options[] = {
|
||||
"Option1",
|
||||
"Option2",
|
||||
"Option3",
|
||||
"Option4",
|
||||
"Option5"
|
||||
"Option2",
|
||||
"Option3",
|
||||
"Option4",
|
||||
"Option5"
|
||||
};
|
||||
|
||||
|
||||
int numberOfRows(WMTableViewDelegate *self, WMTableView *table)
|
||||
int
|
||||
numberOfRows(WMTableViewDelegate *self, WMTableView *table)
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
||||
void *valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
|
||||
void*
|
||||
valueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
/*WMTableView *table = (WMTableView*)WMGetTableColumnTableView(column);*/
|
||||
int i;
|
||||
if (col1[0] == 0) {
|
||||
for (i = 0; i < 20; i++) {
|
||||
char buf[128];
|
||||
for (i = 0; i < 20; i++) {
|
||||
char buf[128];
|
||||
|
||||
sprintf(buf, "Test row %i", i);
|
||||
sprintf(buf, "Test row %i", i);
|
||||
|
||||
col1[i] = wstrdup(buf);
|
||||
col2[i] = 0;
|
||||
}
|
||||
col1[i] = wstrdup(buf);
|
||||
col2[i] = 0;
|
||||
}
|
||||
}
|
||||
if ((int)WMGetTableColumnId(column) == 1)
|
||||
return col1[row];
|
||||
return col1[row];
|
||||
else
|
||||
return (void*)col2[row];
|
||||
return (void*)col2[row];
|
||||
}
|
||||
|
||||
|
||||
void setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
|
||||
void *data)
|
||||
void
|
||||
setValueForCell(WMTableViewDelegate *self, WMTableColumn *column, int row,
|
||||
void *data)
|
||||
{
|
||||
if ((int)WMGetTableColumnId(column) == 1)
|
||||
col1[row] = data;
|
||||
col1[row] = data;
|
||||
else
|
||||
col2[row] = (int)data;
|
||||
col2[row] = (int)data;
|
||||
}
|
||||
|
||||
|
||||
static WMTableViewDelegate delegate = {
|
||||
NULL,
|
||||
numberOfRows,
|
||||
valueForCell,
|
||||
setValueForCell
|
||||
numberOfRows,
|
||||
valueForCell,
|
||||
setValueForCell
|
||||
};
|
||||
|
||||
|
||||
|
||||
void clickedTable(WMWidget *w, void *self)
|
||||
{
|
||||
void
|
||||
clickedTable(WMWidget *w, void *self)
|
||||
{
|
||||
int row = WMGetTableViewClickedRow((WMTableView*)self);
|
||||
|
||||
WMEditTableViewRow(self, row);
|
||||
@@ -82,17 +86,17 @@ main(int argc, char **argv)
|
||||
WMTableView *table;
|
||||
WMTableColumn *col;
|
||||
WMTableColumnDelegate *colDeleg;
|
||||
|
||||
|
||||
WMInitializeApplication("test", &argc, argv);
|
||||
|
||||
|
||||
scr = WMOpenScreen(NULL);
|
||||
|
||||
XSynchronize(WMScreenDisplay(scr), 1);
|
||||
|
||||
|
||||
win = WMCreateWindow(scr, "eweq");
|
||||
WMResizeWidget(win, 400, 200);
|
||||
WMMapWidget(win);
|
||||
|
||||
|
||||
table = WMCreateTableView(win);
|
||||
WMSetTableViewHasHorizontalScroller(table, 0);
|
||||
WMSetViewExpandsToParent(WMWidgetView(table), 10, 10, 10, 10);
|
||||
@@ -101,12 +105,12 @@ main(int argc, char **argv)
|
||||
WMSetTableViewHeaderHeight(table, 20);
|
||||
WMSetTableViewDelegate(table, &delegate);
|
||||
WMSetTableViewAction(table, clickedTable, table);
|
||||
|
||||
|
||||
colDeleg = WTCreateStringEditorDelegate(table);
|
||||
|
||||
|
||||
col = WMCreateTableColumn("Group");
|
||||
WMSetTableColumnWidth(col, 180);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
WMSetTableColumnId(col, (void*)1);
|
||||
|
||||
@@ -115,15 +119,15 @@ main(int argc, char **argv)
|
||||
|
||||
col = WMCreateTableColumn("Package");
|
||||
WMSetTableColumnWidth(col, 140);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
WMSetTableColumnId(col, (void*)2);
|
||||
WMSetTableColumnId(col, (void*)2);
|
||||
|
||||
colDeleg = WTCreateBooleanSwitchDelegate(table);
|
||||
|
||||
col = WMCreateTableColumn("Bool");
|
||||
WMSetTableColumnWidth(col, 50);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMAddTableViewColumn(table, col);
|
||||
WMSetTableColumnDelegate(col, colDeleg);
|
||||
WMSetTableColumnId(col, (void*)2);
|
||||
|
||||
@@ -133,3 +137,4 @@ main(int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+206
-185
@@ -37,7 +37,7 @@ typedef struct {
|
||||
WMTableView *table;
|
||||
WMFont *font;
|
||||
char **options;
|
||||
int count;
|
||||
int count;
|
||||
GC gc;
|
||||
GC selGC;
|
||||
WMColor *textColor;
|
||||
@@ -57,9 +57,9 @@ static char *SelectionColor = "#bbbbcc";
|
||||
|
||||
|
||||
|
||||
static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
WMColor *textColor, WMFont *font, void *data,
|
||||
WMRect rect, Bool selected)
|
||||
static void
|
||||
stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, WMColor *textColor,
|
||||
WMFont *font, void *data, WMRect rect, Bool selected)
|
||||
{
|
||||
int x, y;
|
||||
XRectangle rects[1];
|
||||
@@ -73,26 +73,27 @@ static void stringDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
rects[0].width = rect.size.width-1;
|
||||
rects[0].height = rect.size.height-1;
|
||||
XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted);
|
||||
|
||||
|
||||
if (!selected) {
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
} else {
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
WMDrawString(scr, d, textColor, font, x, y,
|
||||
data, strlen(data));
|
||||
}
|
||||
|
||||
|
||||
XSetClipMask(dpy, gc, None);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
WMPixmap *pixmap, WMRect rect, Bool selected)
|
||||
static void
|
||||
pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc, WMPixmap *pixmap,
|
||||
WMRect rect, Bool selected)
|
||||
{
|
||||
int x, y;
|
||||
XRectangle rects[1];
|
||||
@@ -104,29 +105,29 @@ static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
rects[0].width = rect.size.width-1;
|
||||
rects[0].height = rect.size.height-1;
|
||||
XSetClipRectangles(dpy, gc, 0, 0, rects, 1, YXSorted);
|
||||
|
||||
|
||||
if (!selected) {
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
XFillRectangles(dpy, d, gc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
} else {
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
XFillRectangles(dpy, d, sgc, rects, 1);
|
||||
|
||||
if (pixmap) {
|
||||
size = WMGetPixmapSize(pixmap);
|
||||
x = rect.pos.x + (rect.size.width - size.width) / 2;
|
||||
y = rect.pos.y + (rect.size.height - size.height) / 2;
|
||||
|
||||
WMDrawPixmap(pixmap, d, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XSetClipMask(dpy, gc, None);
|
||||
}
|
||||
|
||||
@@ -135,38 +136,40 @@ static void pixmapDraw(WMScreen *scr, Drawable d, GC gc, GC sgc,
|
||||
|
||||
|
||||
|
||||
static void SECellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
SECellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedSECellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedSECellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
static void beginSECellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
beginSECellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
void *data = WMTableViewDataForCell(strdata->table, column, row);
|
||||
|
||||
@@ -178,35 +181,36 @@ static void beginSECellEdit(WMTableColumnDelegate *self,
|
||||
}
|
||||
|
||||
|
||||
static void endSECellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
endSECellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
StringEditorData *strdata = (StringEditorData*)self->data;
|
||||
char *text;
|
||||
|
||||
WMUnmapWidget(strdata->widget);
|
||||
|
||||
|
||||
text = WMGetTextFieldText(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)text);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
StringEditorData *data = wmalloc(sizeof(StringEditorData));
|
||||
|
||||
|
||||
data->widget = WMCreateTextField(parent);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->textColor = WMBlackColor(scr);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = SECellPainter;
|
||||
delegate->drawSelectedCell = selectedSECellPainter;
|
||||
@@ -221,47 +225,49 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *parent)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void ESCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
ESCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedESCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedESCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
strdata->options[i],
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
static void beginESCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
beginESCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
int data = (int)WMTableViewDataForCell(strdata->table, column, row);
|
||||
|
||||
wassertr(data < strdata->count);
|
||||
|
||||
|
||||
WMSetPopUpButtonSelectedItem(strdata->widget, data);
|
||||
|
||||
|
||||
WMMoveWidget(strdata->widget, rect.pos.x, rect.pos.y);
|
||||
WMResizeWidget(strdata->widget, rect.size.width, rect.size.height+1);
|
||||
|
||||
@@ -269,29 +275,30 @@ static void beginESCellEdit(WMTableColumnDelegate *self,
|
||||
}
|
||||
|
||||
|
||||
static void endESCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
endESCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
EnumSelectorData *strdata = (EnumSelectorData*)self->data;
|
||||
int option;
|
||||
|
||||
WMUnmapWidget(strdata->widget);
|
||||
|
||||
|
||||
option = WMGetPopUpButtonSelectedItem(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)option);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
EnumSelectorData *data = wmalloc(sizeof(EnumSelectorData));
|
||||
|
||||
|
||||
data->widget = WMCreatePopUpButton(parent);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
@@ -299,7 +306,7 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
data->textColor = WMBlackColor(scr);
|
||||
data->count = 0;
|
||||
data->options = NULL;
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = ESCellPainter;
|
||||
delegate->drawSelectedCell = selectedESCellPainter;
|
||||
@@ -310,23 +317,24 @@ WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *parent)
|
||||
}
|
||||
|
||||
|
||||
void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
char **options, int count)
|
||||
void
|
||||
WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate, char **options,
|
||||
int count)
|
||||
{
|
||||
EnumSelectorData *data = (EnumSelectorData*)delegate->data;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0;
|
||||
i < WMGetPopUpButtonNumberOfItems(data->widget);
|
||||
i++) {
|
||||
WMRemovePopUpButtonItem(data->widget, 0);
|
||||
i < WMGetPopUpButtonNumberOfItems(data->widget);
|
||||
i++) {
|
||||
WMRemovePopUpButtonItem(data->widget, 0);
|
||||
}
|
||||
|
||||
|
||||
data->options = options;
|
||||
data->count = count;
|
||||
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
WMAddPopUpButtonItem(data->widget, options[i]);
|
||||
WMAddPopUpButtonItem(data->widget, options[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,51 +342,53 @@ void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static void BSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
BSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
|
||||
|
||||
if (i) {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
} else {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), False);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void selectedBSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedBSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
int i = (int)WMTableViewDataForCell(table, column, row);
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
|
||||
|
||||
if (i) {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, WMGetSystemPixmap(scr, WSICheckMark),
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
} else {
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
}
|
||||
pixmapDraw(scr, d,
|
||||
strdata->gc, strdata->selGC, NULL,
|
||||
WMTableViewRectForCell(table, column, row), True);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void beginBSCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
beginBSCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
WMRect rect = WMTableViewRectForCell(strdata->table, column, row);
|
||||
int data = (int)WMTableViewDataForCell(strdata->table, column, row);
|
||||
|
||||
@@ -390,19 +400,20 @@ static void beginBSCellEdit(WMTableColumnDelegate *self,
|
||||
}
|
||||
|
||||
|
||||
static void endBSCellEdit(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row)
|
||||
static void
|
||||
endBSCellEdit(WMTableColumnDelegate *self, WMTableColumn *column, int row)
|
||||
{
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
BooleanSwitchData *strdata = (BooleanSwitchData*)self->data;
|
||||
int value;
|
||||
|
||||
|
||||
value = WMGetButtonSelected(strdata->widget);
|
||||
WMSetTableViewDataForCell(strdata->table, column, row, (void*)value);
|
||||
WMUnmapWidget(strdata->widget);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
@@ -410,20 +421,20 @@ WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
WMColor *color;
|
||||
|
||||
data->widget = WMCreateSwitchButton(parent);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
W_ReparentView(WMWidgetView(data->widget),
|
||||
WMGetTableViewDocumentView(parent),
|
||||
0, 0);
|
||||
WMSetButtonText(data->widget, NULL);
|
||||
WMSetButtonImagePosition(data->widget, WIPImageOnly);
|
||||
WMSetButtonImage(data->widget, NULL);
|
||||
WMSetButtonAltImage(data->widget, WMGetSystemPixmap(scr, WSICheckMark));
|
||||
|
||||
|
||||
data->table = parent;
|
||||
color = WMCreateNamedColor(scr, SelectionColor, False);
|
||||
WMSetWidgetBackgroundColor(data->widget, color);
|
||||
WMSetWidgetBackgroundColor(data->widget, color);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(color);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = BSCellPainter;
|
||||
delegate->drawSelectedCell = selectedBSCellPainter;
|
||||
@@ -437,46 +448,49 @@ WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void SCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
SCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC, strdata->textColor, strdata->font,
|
||||
WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreateStringDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
StringData *data = wmalloc(sizeof(StringData));
|
||||
|
||||
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->textColor = WMBlackColor(scr);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = SCellPainter;
|
||||
delegate->drawSelectedCell = selectedSCellPainter;
|
||||
@@ -490,44 +504,47 @@ WMTableColumnDelegate *WTCreateStringDelegate(WMTableView *parent)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void PCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
PCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
pixmapDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedPCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedPCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
|
||||
|
||||
pixmapDraw(WMWidgetScreen(table), d,
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
strdata->gc, strdata->selGC,
|
||||
(WMPixmap*)WMTableViewDataForCell(table, column, row),
|
||||
WMTableViewRectForCell(table, column, row),
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table)
|
||||
WMTableColumnDelegate*
|
||||
WTCreatePixmapDelegate(WMTableView *table)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(table);
|
||||
StringData *data = wmalloc(sizeof(StringData));
|
||||
|
||||
|
||||
data->table = table;
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = PCellPainter;
|
||||
delegate->drawSelectedCell = selectedPCellPainter;
|
||||
@@ -541,8 +558,9 @@ WMTableColumnDelegate *WTCreatePixmapDelegate(WMTableView *table)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static void drawPSCell(WMTableColumnDelegate *self, Drawable d,
|
||||
WMTableColumn *column, int row, Bool selected)
|
||||
static void
|
||||
drawPSCell(WMTableColumnDelegate *self, Drawable d, WMTableColumn *column,
|
||||
int row, Bool selected)
|
||||
{
|
||||
StringData *strdata = (StringData*)self->data;
|
||||
WMTableView *table = WMGetTableColumnTableView(column);
|
||||
@@ -554,57 +572,60 @@ static void drawPSCell(WMTableColumnDelegate *self, Drawable d,
|
||||
|
||||
data = WMTableViewDataForCell(table, column, row);
|
||||
|
||||
str = (char*)data[0];
|
||||
str = (char*)data[0];
|
||||
pix = (WMPixmap*)data[1];
|
||||
|
||||
rect = WMTableViewRectForCell(table, column, row);
|
||||
|
||||
|
||||
if (pix) {
|
||||
int owidth = rect.size.width;
|
||||
int owidth = rect.size.width;
|
||||
|
||||
size = WMGetPixmapSize(pix);
|
||||
rect.size.width = size.width;
|
||||
size = WMGetPixmapSize(pix);
|
||||
rect.size.width = size.width;
|
||||
|
||||
pixmapDraw(WMWidgetScreen(table),
|
||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||
strdata->gc, strdata->selGC, pix, rect,
|
||||
selected);
|
||||
pixmapDraw(WMWidgetScreen(table),
|
||||
WMViewXID(WMGetTableViewDocumentView(table)),
|
||||
strdata->gc, strdata->selGC, pix, rect,
|
||||
selected);
|
||||
|
||||
rect.pos.x += size.width-1;
|
||||
rect.size.width = owidth-size.width+1;
|
||||
rect.pos.x += size.width-1;
|
||||
rect.size.width = owidth-size.width+1;
|
||||
}
|
||||
|
||||
|
||||
stringDraw(WMWidgetScreen(table), d, strdata->gc, strdata->selGC,
|
||||
strdata->textColor, strdata->font, str, rect, selected);
|
||||
}
|
||||
|
||||
|
||||
static void PSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
PSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
drawPSCell(self, d, column, row, False);
|
||||
}
|
||||
|
||||
|
||||
static void selectedPSCellPainter(WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d)
|
||||
static void
|
||||
selectedPSCellPainter(WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row, Drawable d)
|
||||
{
|
||||
drawPSCell(self, d, column, row, True);
|
||||
}
|
||||
|
||||
|
||||
WMTableColumnDelegate *WTCreatePixmapStringDelegate(WMTableView *parent)
|
||||
WMTableColumnDelegate*
|
||||
WTCreatePixmapStringDelegate(WMTableView *parent)
|
||||
{
|
||||
WMTableColumnDelegate *delegate = wmalloc(sizeof(WMTableColumnDelegate));
|
||||
WMScreen *scr = WMWidgetScreen(parent);
|
||||
StringData *data = wmalloc(sizeof(StringData));
|
||||
|
||||
|
||||
data->table = parent;
|
||||
data->font = WMSystemFontOfSize(scr, 12);
|
||||
data->gc = WMColorGC(WMWhiteColor(scr));
|
||||
data->selGC = WMColorGC(WMCreateNamedColor(scr, SelectionColor, False));
|
||||
data->textColor = WMBlackColor(scr);
|
||||
|
||||
|
||||
delegate->data = data;
|
||||
delegate->drawCell = PSCellPainter;
|
||||
delegate->drawSelectedCell = selectedPSCellPainter;
|
||||
|
||||
@@ -14,7 +14,7 @@ WMTableColumnDelegate *WTCreateStringEditorDelegate(WMTableView *table);
|
||||
|
||||
WMTableColumnDelegate *WTCreateEnumSelectorDelegate(WMTableView *table);
|
||||
void WTSetEnumSelectorOptions(WMTableColumnDelegate *delegate,
|
||||
char **options, int count);
|
||||
char **options, int count);
|
||||
|
||||
WMTableColumnDelegate *WTCreateBooleanSwitchDelegate(WMTableView *parent);
|
||||
|
||||
|
||||
+569
-520
File diff suppressed because it is too large.
Load diff
+38
-38
@@ -18,98 +18,98 @@ extern const char *WMTableViewSelectionDidChangeNotification;
|
||||
typedef struct WMTableColumnDelegate {
|
||||
void *data;
|
||||
void (*drawCell)(struct WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
void (*drawSelectedCell)(struct WMTableColumnDelegate *self,
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
WMTableColumn *column, int row, Drawable d);
|
||||
|
||||
void (*beginCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row);
|
||||
int row);
|
||||
void (*endCellEdit)(struct WMTableColumnDelegate *self, WMTableColumn *column,
|
||||
int row);
|
||||
int row);
|
||||
} WMTableColumnDelegate;
|
||||
|
||||
|
||||
typedef struct W_TableViewDelegate {
|
||||
void *data;
|
||||
int (*numberOfRows)(struct W_TableViewDelegate *self,
|
||||
WMTableView *table);
|
||||
void *(*valueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row);
|
||||
void (*setValueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row, void *value);
|
||||
int (*numberOfRows)(struct W_TableViewDelegate *self,
|
||||
WMTableView *table);
|
||||
void *(*valueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row);
|
||||
void (*setValueForCell)(struct W_TableViewDelegate *self,
|
||||
WMTableColumn *column, int row, void *value);
|
||||
} WMTableViewDelegate;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
WMTableColumn *WMCreateTableColumn(char *title);
|
||||
|
||||
void WMSetTableColumnWidth(WMTableColumn *column, unsigned width);
|
||||
|
||||
void WMSetTableColumnConstraints(WMTableColumn *column,
|
||||
unsigned minWidth, unsigned maxWidth);
|
||||
|
||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||
WMTableColumnDelegate *delegate);
|
||||
void WMSetTableColumnConstraints(WMTableColumn *column,
|
||||
unsigned minWidth, unsigned maxWidth);
|
||||
|
||||
void WMSetTableColumnDelegate(WMTableColumn *column,
|
||||
WMTableColumnDelegate *delegate);
|
||||
|
||||
|
||||
WMTableView *WMGetTableColumnTableView(WMTableColumn *column);
|
||||
|
||||
|
||||
void WMSetTableColumnId(WMTableColumn *column, void *id);
|
||||
|
||||
void *WMGetTableColumnId(WMTableColumn *column);
|
||||
|
||||
|
||||
|
||||
WMTableView *WMCreateTableView(WMWidget *parent);
|
||||
|
||||
|
||||
|
||||
void WMSetTableViewDataSource(WMTableView *table, void *source);
|
||||
|
||||
void *WMGetTableViewDataSource(WMTableView *table);
|
||||
|
||||
void WMSetTableViewHeaderHeight(WMTableView *table, unsigned height);
|
||||
|
||||
|
||||
void WMAddTableViewColumn(WMTableView *table, WMTableColumn *column);
|
||||
|
||||
void WMSetTableViewDelegate(WMTableView *table, WMTableViewDelegate *delegate);
|
||||
|
||||
void WMSetTableViewAction(WMTableView *table, WMAction *action,
|
||||
void *clientData);
|
||||
void WMSetTableViewAction(WMTableView *table, WMAction *action,
|
||||
void *clientData);
|
||||
|
||||
void *WMGetTableViewClickedColumn(WMTableView *table);
|
||||
|
||||
int WMGetTableViewClickedRow(WMTableView *table);
|
||||
|
||||
WMArray *WMGetTableViewSelectedRows(WMTableView *table);
|
||||
|
||||
|
||||
WMView *WMGetTableViewDocumentView(WMTableView *table);
|
||||
|
||||
void WMEditTableViewRow(WMTableView *table, int row);
|
||||
|
||||
void WMSelectTableViewRow(WMTableView *table, int row);
|
||||
|
||||
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
void *WMTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
|
||||
void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row, void *data);
|
||||
|
||||
WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
void WMSetTableViewDataForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row, void *data);
|
||||
|
||||
WMRect WMTableViewRectForCell(WMTableView *table, WMTableColumn *column,
|
||||
int row);
|
||||
|
||||
void WMSetTableViewBackgroundColor(WMTableView *table, WMColor *color);
|
||||
|
||||
void WMSetTableViewGridColor(WMTableView *table, WMColor *color);
|
||||
|
||||
void WMSetTableViewRowHeight(WMTableView *table, int height);
|
||||
|
||||
void WMReloadTableView(WMTableView *table);
|
||||
|
||||
void WMSetTableViewRowHeight(WMTableView *table, int height);
|
||||
|
||||
void WMReloadTableView(WMTableView *table);
|
||||
|
||||
void WMNoteTableViewNumberOfRowsChanged(WMTableView *table);
|
||||
|
||||
|
||||
void WMScrollTableViewRowToVisible(WMTableView *table, int row);
|
||||
|
||||
|
||||
void WMSetTableViewHasHorizontalScroller(WMTableView *tPtr, Bool flag);
|
||||
|
||||
|
||||
|
||||
+52
-52
@@ -2,9 +2,9 @@
|
||||
* Demo user widget for WINGs
|
||||
*
|
||||
* Author: Alfredo K. Kojima
|
||||
*
|
||||
*
|
||||
* This file is in the public domain.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*
|
||||
* Include the WINGs private data header.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <WINGs/WINGsP.h>
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
* Define the widget "class"
|
||||
*/
|
||||
typedef struct W_MyWidget {
|
||||
/* these two fields must be present in all your widgets in this
|
||||
/* these two fields must be present in all your widgets in this
|
||||
* exact position */
|
||||
W_Class widgetClass;
|
||||
WMView *view;
|
||||
|
||||
|
||||
/* put your stuff here */
|
||||
char *text;
|
||||
|
||||
|
||||
} _MyWidget;
|
||||
|
||||
|
||||
@@ -50,16 +50,16 @@ static void handleActionEvents(XEvent *event, void *data);
|
||||
|
||||
|
||||
/*
|
||||
* Delegates
|
||||
* Delegates
|
||||
* See the source for the other widgets to see how to use.
|
||||
* You won't need to use this most of the time.
|
||||
*/
|
||||
static W_ViewDelegate _MyWidgetDelegate = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ InitMyWidget(WMScreen *scr)
|
||||
{
|
||||
/* register our widget with WINGs and get our widget class ID */
|
||||
if (!myWidgetClass) {
|
||||
myWidgetClass = W_RegisterUserWidget();
|
||||
myWidgetClass = W_RegisterUserWidget();
|
||||
}
|
||||
|
||||
|
||||
return myWidgetClass;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ MyWidget*
|
||||
CreateMyWidget(WMWidget *parent)
|
||||
{
|
||||
MyWidget *mPtr;
|
||||
|
||||
|
||||
/* allocate some storage for our new widget instance */
|
||||
mPtr = wmalloc(sizeof(MyWidget));
|
||||
/* initialize it */
|
||||
@@ -99,17 +99,17 @@ CreateMyWidget(WMWidget *parent)
|
||||
/* set the class ID */
|
||||
mPtr->widgetClass = myWidgetClass;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Create the view for our widget.
|
||||
* Note: the Window for the view is only created after the view is
|
||||
* realized with W_RealizeView()
|
||||
*
|
||||
*
|
||||
* Consider the returned view as read-only.
|
||||
*/
|
||||
mPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!mPtr->view) {
|
||||
wfree(mPtr);
|
||||
return NULL;
|
||||
wfree(mPtr);
|
||||
return NULL;
|
||||
}
|
||||
/* always do this */
|
||||
mPtr->view->self = mPtr;
|
||||
@@ -121,8 +121,8 @@ CreateMyWidget(WMWidget *parent)
|
||||
* Intercept some events for our widget, so that we can handle them.
|
||||
*/
|
||||
WMCreateEventHandler(mPtr->view, ExposureMask /* this allows us to know when we should paint */
|
||||
|StructureNotifyMask, /* this allows us to know things like when we are destroyed */
|
||||
handleEvents, mPtr);
|
||||
|StructureNotifyMask, /* this allows us to know things like when we are destroyed */
|
||||
handleEvents, mPtr);
|
||||
|
||||
/*
|
||||
* Intercept some other events. This could be merged with the above
|
||||
@@ -146,14 +146,14 @@ paintMyWidget(_MyWidget *mPtr)
|
||||
|
||||
|
||||
if (mPtr->text) {
|
||||
|
||||
color = WMWhiteColor(scr);
|
||||
|
||||
W_PaintText(mPtr->view, mPtr->view->window, scr->normalFont, 0, 0,
|
||||
mPtr->view->size.width, WACenter, color,
|
||||
False, mPtr->text, strlen(mPtr->text));
|
||||
|
||||
WMReleaseColor(color);
|
||||
|
||||
color = WMWhiteColor(scr);
|
||||
|
||||
W_PaintText(mPtr->view, mPtr->view->window, scr->normalFont, 0, 0,
|
||||
mPtr->view->size.width, WACenter, color,
|
||||
False, mPtr->text, strlen(mPtr->text));
|
||||
|
||||
WMReleaseColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,17 +165,17 @@ handleEvents(XEvent *event, void *data)
|
||||
_MyWidget *mPtr = (_MyWidget*)data;
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintMyWidget(mPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyMyWidget(mPtr);
|
||||
break;
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintMyWidget(mPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyMyWidget(mPtr);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,10 +186,10 @@ handleActionEvents(XEvent *event, void *data)
|
||||
_MyWidget *mPtr = (_MyWidget*)data;
|
||||
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
XBell(mPtr->view->screen->display, 100);
|
||||
XBell(mPtr->view->screen->display, 100);
|
||||
break;
|
||||
case ButtonPress:
|
||||
XBell(mPtr->view->screen->display, 100);
|
||||
XBell(mPtr->view->screen->display, 100);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,12 +200,12 @@ SetMyWidgetText(MyWidget *mPtr, char *text)
|
||||
CHECK_CLASS(mPtr, myWidgetClass);
|
||||
|
||||
if (mPtr->text)
|
||||
wfree(mPtr->text);
|
||||
|
||||
wfree(mPtr->text);
|
||||
|
||||
mPtr->text = wstrdup(text);
|
||||
|
||||
|
||||
if (W_VIEW_MAPPED(mPtr->view)) {
|
||||
paintMyWidget(mPtr);
|
||||
paintMyWidget(mPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,12 +215,12 @@ static void
|
||||
destroyMyWidget(_MyWidget *mPtr)
|
||||
{
|
||||
/*
|
||||
* Free all data we allocated for our widget.
|
||||
* Free all data we allocated for our widget.
|
||||
*/
|
||||
|
||||
|
||||
if (mPtr->text)
|
||||
wfree(mPtr->text);
|
||||
|
||||
wfree(mPtr->text);
|
||||
|
||||
wfree(mPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/*
|
||||
* Header for demo widget.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct W_MyWidget MyWidget;
|
||||
|
||||
@@ -22,30 +22,31 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
WMInitializeApplication("Test", &argc, argv);
|
||||
|
||||
|
||||
if (!dpy) {
|
||||
wfatal("could not open display");
|
||||
exit(1);
|
||||
wfatal("could not open display");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
scr = WMCreateSimpleApplicationScreen(dpy);
|
||||
|
||||
/* init our widget */
|
||||
InitMyWidget(scr);
|
||||
|
||||
|
||||
win = WMCreateWindow(scr, "test");
|
||||
WMResizeWidget(win, 150, 50);
|
||||
|
||||
|
||||
thing = CreateMyWidget(win);
|
||||
SetMyWidgetText(thing, "The Test");
|
||||
WMResizeWidget(thing, 100, 20);
|
||||
WMMoveWidget(thing, 10, 10);
|
||||
|
||||
|
||||
WMRealizeWidget(win);
|
||||
WMMapSubwidgets(win);
|
||||
WMMapWidget(win);
|
||||
|
||||
|
||||
WMScreenMainLoop(scr);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+76
-75
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Author: Len Trigg <trigg@cs.waikato.ac.nz>
|
||||
* Author: Len Trigg <trigg@cs.waikato.ac.nz>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Update: Franck Wolff <frawolff@club-internet.fr>
|
||||
-----------------------------------------------------------------------
|
||||
List of updated functions :
|
||||
- main :
|
||||
add -s option for a save panel...
|
||||
-----------------------------------------------------------------------
|
||||
*/
|
||||
Update: Franck Wolff <frawolff@club-internet.fr>
|
||||
-----------------------------------------------------------------------
|
||||
List of updated functions :
|
||||
- main :
|
||||
add -s option for a save panel...
|
||||
-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -34,23 +34,23 @@ char *ProgName;
|
||||
|
||||
void usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage:\n"
|
||||
"\t%s [-options]\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -s\t\tSave panel (default open panel)\n"
|
||||
" -i <str>\tInitial directory (default /)\n"
|
||||
" -t <str>\tQuery window title (default none)\n"
|
||||
"\n"
|
||||
"information:\n"
|
||||
"\t%s pops up a WindowMaker style file selection panel.\n"
|
||||
"\n"
|
||||
"version:\n"
|
||||
"\t%s\n"
|
||||
,ProgName,ProgName,__DATE__
|
||||
);
|
||||
exit(0);
|
||||
fprintf(stderr,
|
||||
"usage:\n"
|
||||
"\t%s [-options]\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -s\t\tSave panel (default open panel)\n"
|
||||
" -i <str>\tInitial directory (default /)\n"
|
||||
" -t <str>\tQuery window title (default none)\n"
|
||||
"\n"
|
||||
"information:\n"
|
||||
"\t%s pops up a WindowMaker style file selection panel.\n"
|
||||
"\n"
|
||||
"version:\n"
|
||||
"\t%s\n"
|
||||
,ProgName,ProgName,__DATE__
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#define OPEN_PANEL_TYPE 0
|
||||
@@ -58,68 +58,69 @@ void usage(void)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Display *dpy = XOpenDisplay("");
|
||||
WMScreen *scr;
|
||||
WMPixmap *pixmap;
|
||||
WMOpenPanel *oPanel;
|
||||
WMSavePanel *sPanel;
|
||||
/* RImage *image;*/
|
||||
char *title = NULL;
|
||||
char *initial = "/";
|
||||
int ch;
|
||||
int panelType = OPEN_PANEL_TYPE;
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
Display *dpy = XOpenDisplay("");
|
||||
WMScreen *scr;
|
||||
WMPixmap *pixmap;
|
||||
WMOpenPanel *oPanel;
|
||||
WMSavePanel *sPanel;
|
||||
/* RImage *image;*/
|
||||
char *title = NULL;
|
||||
char *initial = "/";
|
||||
int ch;
|
||||
int panelType = OPEN_PANEL_TYPE;
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
if (!dpy) {
|
||||
puts("could not open display");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
WMInitializeApplication("WMFile", &argc, argv);
|
||||
|
||||
ProgName = argv[0];
|
||||
|
||||
while((ch = getopt(argc, argv, "si:ht:")) != -1)
|
||||
switch(ch)
|
||||
{
|
||||
case 's':
|
||||
panelType = SAVE_PANEL_TYPE;
|
||||
break;
|
||||
case 'i':
|
||||
initial = optarg;
|
||||
break;
|
||||
case 't':
|
||||
title = optarg;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
if (!dpy) {
|
||||
puts("could not open display");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
WMInitializeApplication("WMFile", &argc, argv);
|
||||
|
||||
ProgName = argv[0];
|
||||
|
||||
while((ch = getopt(argc, argv, "si:ht:")) != -1)
|
||||
switch(ch)
|
||||
{
|
||||
case 's':
|
||||
panelType = SAVE_PANEL_TYPE;
|
||||
break;
|
||||
case 'i':
|
||||
initial = optarg;
|
||||
break;
|
||||
case 't':
|
||||
title = optarg;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
for(; optind <argc; optind++)
|
||||
usage();
|
||||
usage();
|
||||
|
||||
scr = WMCreateSimpleApplicationScreen(dpy);
|
||||
|
||||
|
||||
|
||||
|
||||
pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
|
||||
WMSetApplicationIconPixmap(scr, pixmap);
|
||||
WMReleasePixmap(pixmap);
|
||||
if (panelType == SAVE_PANEL_TYPE) {
|
||||
sPanel = WMGetSavePanel(scr);
|
||||
if (WMRunModalFilePanelForDirectory(sPanel, NULL, initial,
|
||||
/*title*/ NULL, NULL) == True)
|
||||
printf("%s\n", WMGetFilePanelFileName(sPanel));
|
||||
else
|
||||
printf("\n");
|
||||
sPanel = WMGetSavePanel(scr);
|
||||
if (WMRunModalFilePanelForDirectory(sPanel, NULL, initial,
|
||||
/*title*/ NULL, NULL) == True)
|
||||
printf("%s\n", WMGetFilePanelFileName(sPanel));
|
||||
else
|
||||
printf("\n");
|
||||
} else {
|
||||
oPanel = WMGetOpenPanel(scr);
|
||||
if (WMRunModalFilePanelForDirectory(oPanel, NULL, initial,
|
||||
/*title*/ NULL, NULL) == True)
|
||||
printf("%s\n", WMGetFilePanelFileName(oPanel));
|
||||
else
|
||||
printf("\n");
|
||||
oPanel = WMGetOpenPanel(scr);
|
||||
if (WMRunModalFilePanelForDirectory(oPanel, NULL, initial,
|
||||
/*title*/ NULL, NULL) == True)
|
||||
printf("%s\n", WMGetFilePanelFileName(oPanel));
|
||||
else
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+65
-62
@@ -1,6 +1,6 @@
|
||||
|
||||
/*
|
||||
* Author: Len Trigg <trigg@cs.waikato.ac.nz>
|
||||
* Author: Len Trigg <trigg@cs.waikato.ac.nz>
|
||||
*/
|
||||
|
||||
|
||||
@@ -23,78 +23,81 @@ wAbort()
|
||||
|
||||
char *ProgName;
|
||||
|
||||
void usage(void)
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage:\n"
|
||||
"\t%s [-options]\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -i <str>\tInitial entry contents (default none)\n"
|
||||
" -p <str>\tPrompt message (default none)\n"
|
||||
" -t <str>\tQuery window title (default none)\n"
|
||||
"\n"
|
||||
"information:\n"
|
||||
"\t%s pops up a WindowMaker style input panel.\n"
|
||||
"\n"
|
||||
"version:\n"
|
||||
"\t%s\n"
|
||||
,ProgName,ProgName,__DATE__
|
||||
);
|
||||
exit(0);
|
||||
fprintf(stderr,
|
||||
"usage:\n"
|
||||
"\t%s [-options]\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -i <str>\tInitial entry contents (default none)\n"
|
||||
" -p <str>\tPrompt message (default none)\n"
|
||||
" -t <str>\tQuery window title (default none)\n"
|
||||
"\n"
|
||||
"information:\n"
|
||||
"\t%s pops up a WindowMaker style input panel.\n"
|
||||
"\n"
|
||||
"version:\n"
|
||||
"\t%s\n"
|
||||
,ProgName,ProgName,__DATE__
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
Display *dpy = XOpenDisplay("");
|
||||
WMScreen *scr;
|
||||
WMPixmap *pixmap;
|
||||
char *title = NULL;
|
||||
char *prompt = NULL;
|
||||
char *initial = NULL;
|
||||
char *result = NULL;
|
||||
int ch;
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
Display *dpy = XOpenDisplay("");
|
||||
WMScreen *scr;
|
||||
WMPixmap *pixmap;
|
||||
char *title = NULL;
|
||||
char *prompt = NULL;
|
||||
char *initial = NULL;
|
||||
char *result = NULL;
|
||||
int ch;
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
WMInitializeApplication("WMQuery", &argc, argv);
|
||||
|
||||
ProgName = argv[0];
|
||||
WMInitializeApplication("WMQuery", &argc, argv);
|
||||
|
||||
if (!dpy) {
|
||||
puts("could not open display");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while((ch = getopt(argc, argv, "i:hp:t:")) != -1)
|
||||
switch(ch)
|
||||
{
|
||||
case 'i':
|
||||
initial = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
prompt = optarg;
|
||||
break;
|
||||
case 't':
|
||||
title = optarg;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
ProgName = argv[0];
|
||||
|
||||
if (!dpy) {
|
||||
puts("could not open display");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for(; optind <argc; optind++)
|
||||
usage();
|
||||
while((ch = getopt(argc, argv, "i:hp:t:")) != -1)
|
||||
switch(ch)
|
||||
{
|
||||
case 'i':
|
||||
initial = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
prompt = optarg;
|
||||
break;
|
||||
case 't':
|
||||
title = optarg;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
for(; optind <argc; optind++)
|
||||
usage();
|
||||
|
||||
|
||||
scr = WMCreateSimpleApplicationScreen(dpy);
|
||||
scr = WMCreateSimpleApplicationScreen(dpy);
|
||||
|
||||
pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
|
||||
pixmap = WMCreatePixmapFromXPMData(scr, GNUSTEP_XPM);
|
||||
|
||||
WMSetApplicationIconPixmap(scr, pixmap); WMReleasePixmap(pixmap);
|
||||
WMSetApplicationIconPixmap(scr, pixmap); WMReleasePixmap(pixmap);
|
||||
|
||||
if ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, "OK", "Cancel")) != NULL)
|
||||
printf("%s\n", result);
|
||||
else
|
||||
printf("\n");
|
||||
return 0;
|
||||
if ((result = WMRunInputPanel(scr, NULL, title, prompt, initial, "OK", "Cancel")) != NULL)
|
||||
printf("%s\n", result);
|
||||
else
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+8
-7
@@ -28,7 +28,7 @@ Display *dpy;
|
||||
int windowCount = 0;
|
||||
|
||||
void
|
||||
closeAction(WMWidget *self, void *data)
|
||||
closeAction(WMWidget *self, void *data)
|
||||
{
|
||||
WMDestroyWidget(self);
|
||||
windowCount--;
|
||||
@@ -117,13 +117,13 @@ testFrame(WMScreen *scr)
|
||||
|
||||
|
||||
/*static void
|
||||
resizedWindow(void *self, WMNotification *notif)
|
||||
{
|
||||
WMView *view = (WMView*)WMGetNotificationObject(notif);
|
||||
WMSize size = WMGetViewSize(view);
|
||||
resizedWindow(void *self, WMNotification *notif)
|
||||
{
|
||||
WMView *view = (WMView*)WMGetNotificationObject(notif);
|
||||
WMSize size = WMGetViewSize(view);
|
||||
|
||||
WMResizeWidget((WMWidget*)self, size.width, size.height);
|
||||
}*/
|
||||
WMResizeWidget((WMWidget*)self, size.width, size.height);
|
||||
}*/
|
||||
|
||||
void
|
||||
testBox(WMScreen *scr)
|
||||
@@ -1071,3 +1071,4 @@ main(int argc, char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+67
-66
@@ -55,29 +55,29 @@ typedef struct {
|
||||
* range INT_MIN+1 to INT_MAX
|
||||
*/
|
||||
enum {
|
||||
WMDesktopWindowLevel = -1000, /* GNUstep addition */
|
||||
WMNormalWindowLevel = 0,
|
||||
WMFloatingWindowLevel = 3,
|
||||
WMSubmenuWindowLevel = 3,
|
||||
WMTornOffMenuWindowLevel = 3,
|
||||
WMMainMenuWindowLevel = 20,
|
||||
WMDockWindowLevel = 21, /* Deprecated - use NSStatusWindowLevel */
|
||||
WMStatusWindowLevel = 21,
|
||||
WMModalPanelWindowLevel = 100,
|
||||
WMPopUpMenuWindowLevel = 101,
|
||||
WMScreenSaverWindowLevel = 1000
|
||||
WMDesktopWindowLevel = -1000, /* GNUstep addition */
|
||||
WMNormalWindowLevel = 0,
|
||||
WMFloatingWindowLevel = 3,
|
||||
WMSubmenuWindowLevel = 3,
|
||||
WMTornOffMenuWindowLevel = 3,
|
||||
WMMainMenuWindowLevel = 20,
|
||||
WMDockWindowLevel = 21, /* Deprecated - use NSStatusWindowLevel */
|
||||
WMStatusWindowLevel = 21,
|
||||
WMModalPanelWindowLevel = 100,
|
||||
WMPopUpMenuWindowLevel = 101,
|
||||
WMScreenSaverWindowLevel = 1000
|
||||
};
|
||||
|
||||
|
||||
/* window attributes */
|
||||
enum {
|
||||
WMBorderlessWindowMask = 0,
|
||||
WMTitledWindowMask = 1,
|
||||
WMClosableWindowMask = 2,
|
||||
WMMiniaturizableWindowMask = 4,
|
||||
WMResizableWindowMask = 8,
|
||||
WMIconWindowMask = 64,
|
||||
WMMiniWindowMask = 128
|
||||
WMBorderlessWindowMask = 0,
|
||||
WMTitledWindowMask = 1,
|
||||
WMClosableWindowMask = 2,
|
||||
WMMiniaturizableWindowMask = 4,
|
||||
WMResizableWindowMask = 8,
|
||||
WMIconWindowMask = 64,
|
||||
WMMiniWindowMask = 128
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -400,18 +400,18 @@ typedef struct WMAlertPanel {
|
||||
typedef struct WMGenericPanel {
|
||||
WMWindow *win;
|
||||
WMBox *vbox;
|
||||
|
||||
|
||||
WMLabel *iLbl;
|
||||
WMLabel *tLbl;
|
||||
|
||||
|
||||
WMFrame *line;
|
||||
|
||||
|
||||
WMFrame *content;
|
||||
|
||||
|
||||
WMBox *buttonBox;
|
||||
WMButton *defBtn;
|
||||
WMButton *altBtn;
|
||||
|
||||
|
||||
short result;
|
||||
} WMGenericPanel;
|
||||
|
||||
@@ -443,7 +443,7 @@ typedef struct {
|
||||
unsigned short right; /* right margin marker */
|
||||
unsigned short first; /* indentation marker for first line only */
|
||||
unsigned short body; /* body indentation marker */
|
||||
unsigned short retainCount;
|
||||
unsigned short retainCount;
|
||||
} WMRulerMargins;
|
||||
/* All indentation and tab markers are _relative_ to the left margin marker */
|
||||
|
||||
@@ -464,10 +464,11 @@ typedef void WMAction2(void *self, void *clientData);
|
||||
typedef void WMListDrawProc(WMList *lPtr, int index, Drawable d, char *text,
|
||||
int state, WMRect *rect);
|
||||
|
||||
|
||||
/*
|
||||
typedef void WMSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
unsigned int oldWidth,
|
||||
unsigned int oldHeight);
|
||||
unsigned int oldWidth,
|
||||
unsigned int oldHeight);
|
||||
*/
|
||||
|
||||
typedef void WMSplitViewConstrainProc(WMSplitView *sPtr, int dividerIndex,
|
||||
@@ -499,7 +500,7 @@ typedef struct WMTextFieldDelegate {
|
||||
void (*didBeginEditing)(struct WMTextFieldDelegate *self,
|
||||
WMNotification *notif);
|
||||
|
||||
void (*didChange)(struct WMTextFieldDelegate *self,
|
||||
void (*didChange)(struct WMTextFieldDelegate *self,
|
||||
WMNotification *notif);
|
||||
|
||||
void (*didEndEditing)(struct WMTextFieldDelegate *self,
|
||||
@@ -532,7 +533,7 @@ typedef struct WMTabViewDelegate {
|
||||
void (*didSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView,
|
||||
WMTabViewItem *item);
|
||||
|
||||
Bool (*shouldSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView,
|
||||
Bool (*shouldSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView,
|
||||
WMTabViewItem *item);
|
||||
|
||||
void (*willSelectItem)(struct WMTabViewDelegate *self, WMTabView *tabView,
|
||||
@@ -563,29 +564,29 @@ typedef struct W_DragOperationtItem WMDragOperationItem;
|
||||
|
||||
|
||||
typedef struct W_DragSourceProcs {
|
||||
WMArray* (*dropDataTypes)(WMView *self);
|
||||
WMArray* (*dropDataTypes)(WMView *self);
|
||||
WMDragOperationType (*wantedDropOperation)(WMView *self);
|
||||
WMArray* (*askedOperations)(WMView *self);
|
||||
Bool (*acceptDropOperation)(WMView *self, WMDragOperationType operation);
|
||||
WMArray* (*askedOperations)(WMView *self);
|
||||
Bool (*acceptDropOperation)(WMView *self, WMDragOperationType operation);
|
||||
void (*beganDrag)(WMView *self, WMPoint *point);
|
||||
void (*endedDrag)(WMView *self, WMPoint *point, Bool deposited);
|
||||
WMData* (*fetchDragData)(WMView *self, char *type);
|
||||
/* Bool (*ignoreModifierKeysWhileDragging)(WMView *view);*/
|
||||
/*Bool (*ignoreModifierKeysWhileDragging)(WMView *view);*/
|
||||
} WMDragSourceProcs;
|
||||
|
||||
|
||||
|
||||
typedef struct W_DragDestinationProcs {
|
||||
void (*prepareForDragOperation)(WMView *self);
|
||||
WMArray* (*requiredDataTypes)(WMView *self, WMDragOperationType request,
|
||||
void (*prepareForDragOperation)(WMView *self);
|
||||
WMArray* (*requiredDataTypes)(WMView *self, WMDragOperationType request,
|
||||
WMArray *sourceDataTypes);
|
||||
WMDragOperationType (*allowedOperation)(WMView *self,
|
||||
WMDragOperationType request,
|
||||
WMArray *sourceDataTypes);
|
||||
Bool (*inspectDropData)(WMView *self, WMArray *dropData);
|
||||
void (*performDragOperation)(WMView *self, WMArray *dropData,
|
||||
Bool (*inspectDropData)(WMView *self, WMArray *dropData);
|
||||
void (*performDragOperation)(WMView *self, WMArray *dropData,
|
||||
WMArray *operations, WMPoint *dropLocation);
|
||||
void (*concludeDragOperation)(WMView *self);
|
||||
void (*concludeDragOperation)(WMView *self);
|
||||
} WMDragDestinationProcs;
|
||||
|
||||
|
||||
@@ -621,7 +622,7 @@ char* WMPathForResourceOfType(char *resource, char *ext);
|
||||
WMScreen* WMOpenScreen(const char *display);
|
||||
|
||||
WMScreen* WMCreateScreenWithRContext(Display *display, int screen,
|
||||
RContext *context);
|
||||
RContext *context);
|
||||
|
||||
WMScreen* WMCreateScreen(Display *display, int screen);
|
||||
|
||||
@@ -663,10 +664,10 @@ int WMHandleEvent(XEvent *event);
|
||||
Bool WMScreenPending(WMScreen *scr);
|
||||
|
||||
void WMCreateEventHandler(WMView *view, unsigned long mask,
|
||||
WMEventProc *eventProc, void *clientData);
|
||||
WMEventProc *eventProc, void *clientData);
|
||||
|
||||
void WMDeleteEventHandler(WMView *view, unsigned long mask,
|
||||
WMEventProc *eventProc, void *clientData);
|
||||
WMEventProc *eventProc, void *clientData);
|
||||
|
||||
int WMIsDoubleClick(XEvent *event);
|
||||
|
||||
@@ -681,13 +682,13 @@ void WMMaskEvent(Display *dpy, long mask, XEvent *event);
|
||||
|
||||
|
||||
Bool WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
|
||||
WMSelectionProcs *procs, void *cdata);
|
||||
WMSelectionProcs *procs, void *cdata);
|
||||
|
||||
void WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp);
|
||||
|
||||
Bool WMRequestSelection(WMView *view, Atom selection, Atom target,
|
||||
Time timestamp, WMSelectionCallback *callback,
|
||||
void *cdata);
|
||||
Bool WMRequestSelection(WMView *view, Atom selection, Atom target,
|
||||
Time timestamp, WMSelectionCallback *callback,
|
||||
void *cdata);
|
||||
|
||||
|
||||
extern char *WMSelectionOwnerDidChangeNotification;
|
||||
@@ -814,7 +815,7 @@ GC WMColorGC(WMColor *color);
|
||||
|
||||
WMPixel WMColorPixel(WMColor *color);
|
||||
|
||||
void WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y,
|
||||
void WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y,
|
||||
unsigned int width, unsigned int height);
|
||||
|
||||
void WMReleaseColor(WMColor *color);
|
||||
@@ -909,7 +910,7 @@ void WMRedisplayWidget(WMWidget *w);
|
||||
|
||||
void WMSetViewNotifySizeChanges(WMView *view, Bool flag);
|
||||
|
||||
void WMSetViewExpandsToParent(WMView *view, int topOffs, int leftOffs,
|
||||
void WMSetViewExpandsToParent(WMView *view, int topOffs, int leftOffs,
|
||||
int rightOffs, int bottomOffs);
|
||||
|
||||
WMSize WMGetViewSize(WMView *view);
|
||||
@@ -994,16 +995,16 @@ void WMCloseWindow(WMWindow *win);
|
||||
void WMSetButtonAction(WMButton *bPtr, WMAction *action, void *clientData);
|
||||
|
||||
#define WMCreateCommandButton(parent) \
|
||||
WMCreateCustomButton((parent), WBBSpringLoadedMask\
|
||||
|WBBPushInMask\
|
||||
|WBBPushLightMask\
|
||||
|WBBPushChangeMask)
|
||||
WMCreateCustomButton((parent), WBBSpringLoadedMask\
|
||||
|WBBPushInMask\
|
||||
|WBBPushLightMask\
|
||||
|WBBPushChangeMask)
|
||||
|
||||
#define WMCreateRadioButton(parent) \
|
||||
WMCreateButton((parent), WBTRadio)
|
||||
WMCreateButton((parent), WBTRadio)
|
||||
|
||||
#define WMCreateSwitchButton(parent) \
|
||||
WMCreateButton((parent), WBTSwitch)
|
||||
WMCreateButton((parent), WBTSwitch)
|
||||
|
||||
WMButton* WMCreateButton(WMWidget *parent, WMButtonType type);
|
||||
|
||||
@@ -1138,7 +1139,7 @@ extern char *WMTextDidEndEditingNotification;
|
||||
|
||||
WMScroller* WMCreateScroller(WMWidget *parent);
|
||||
|
||||
void WMSetScrollerParameters(WMScroller *sPtr, float floatValue,
|
||||
void WMSetScrollerParameters(WMScroller *sPtr, float floatValue,
|
||||
float knobProportion);
|
||||
|
||||
float WMGetScrollerKnobProportion(WMScroller *sPtr);
|
||||
@@ -1149,8 +1150,8 @@ WMScrollerPart WMGetScrollerHitPart(WMScroller *sPtr);
|
||||
|
||||
void WMSetScrollerAction(WMScroller *sPtr, WMAction *action, void *clientData);
|
||||
|
||||
void WMSetScrollerArrowsPosition(WMScroller *sPtr,
|
||||
WMScrollArrowPosition position);
|
||||
void WMSetScrollerArrowsPosition(WMScroller *sPtr,
|
||||
WMScrollArrowPosition position);
|
||||
|
||||
extern char *WMScrollerDidScrollNotification;
|
||||
|
||||
@@ -1277,7 +1278,7 @@ WMArray* WMGetBrowserPaths(WMBrowser *bPtr);
|
||||
|
||||
void WMSetBrowserAction(WMBrowser *bPtr, WMAction *action, void *clientData);
|
||||
|
||||
void WMSetBrowserDoubleAction(WMBrowser *bPtr, WMAction *action,
|
||||
void WMSetBrowserDoubleAction(WMBrowser *bPtr, WMAction *action,
|
||||
void *clientData);
|
||||
|
||||
WMListItem* WMGetBrowserSelectedItemInColumn(WMBrowser *bPtr, int column);
|
||||
@@ -1358,18 +1359,18 @@ void WMSetMenuItemMixedStatePixmap(WMMenuItem *item, WMPixmap *pixmap);
|
||||
WMPixmap* WMGetMenuItemMixedStatePixmap(WMMenuItem *item);
|
||||
|
||||
/*void WMSetMenuItemSubmenu(WMMenuItem *item, WMMenu *submenu);
|
||||
|
||||
|
||||
|
||||
WMMenu* WMGetMenuItemSubmenu(WMMenuItem *item);
|
||||
|
||||
Bool WMGetMenuItemHasSubmenu(WMMenuItem *item);
|
||||
*/
|
||||
*/
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
WMPopUpButton* WMCreatePopUpButton(WMWidget *parent);
|
||||
|
||||
void WMSetPopUpButtonAction(WMPopUpButton *sPtr, WMAction *action,
|
||||
void WMSetPopUpButtonAction(WMPopUpButton *sPtr, WMAction *action,
|
||||
void *clientData);
|
||||
|
||||
void WMSetPopUpButtonPullsDown(WMPopUpButton *bPtr, Bool flag);
|
||||
@@ -1529,8 +1530,8 @@ void WMSetSplitViewConstrainProc(WMSplitView *sPtr,
|
||||
WMSplitViewConstrainProc *proc);
|
||||
|
||||
/*
|
||||
void WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
WMSplitViewResizeSubviewsProc *proc);
|
||||
void WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
WMSplitViewResizeSubviewsProc *proc);
|
||||
*/
|
||||
|
||||
int WMGetSplitViewDividerThickness(WMSplitView *sPtr);
|
||||
@@ -1568,9 +1569,9 @@ WMText* WMCreateTextForDocumentType(WMWidget *parent, WMAction *parser,
|
||||
|
||||
void WMSetTextDelegate(WMText *tPtr, WMTextDelegate *delegate);
|
||||
|
||||
void WMFreezeText(WMText *tPtr);
|
||||
void WMFreezeText(WMText *tPtr);
|
||||
|
||||
#define WMRefreshText(tPtr) WMThawText((tPtr))
|
||||
#define WMRefreshText(tPtr) WMThawText((tPtr))
|
||||
|
||||
void WMThawText(WMText *tPtr);
|
||||
|
||||
@@ -1770,9 +1771,9 @@ void WMSetBoxHorizontal(WMBox *box, Bool flag);
|
||||
|
||||
/* ....................................................................... */
|
||||
|
||||
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||
char *defaultButton, char *alternateButton,
|
||||
char *otherButton);
|
||||
int WMRunAlertPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||
char *defaultButton, char *alternateButton,
|
||||
char *otherButton);
|
||||
|
||||
/* you can free the returned string */
|
||||
char* WMRunInputPanel(WMScreen *app, WMWindow *owner, char *title, char *msg,
|
||||
|
||||
+10
-9
@@ -79,7 +79,7 @@ typedef struct W_Color {
|
||||
short refCount;
|
||||
GC gc;
|
||||
struct {
|
||||
unsigned int exact:1;
|
||||
unsigned int exact:1;
|
||||
} flags;
|
||||
} W_Color;
|
||||
|
||||
@@ -196,13 +196,13 @@ typedef struct W_Screen {
|
||||
struct W_Window *windowList; /* list of windows in the app */
|
||||
|
||||
Window groupLeader; /* the leader of the application */
|
||||
/* also used for other things */
|
||||
/* also used for other things */
|
||||
|
||||
struct W_SelectionHandlers *selectionHandlerList;
|
||||
|
||||
struct {
|
||||
unsigned int hasAppIcon:1;
|
||||
unsigned int simpleApplication:1;
|
||||
unsigned int hasAppIcon:1;
|
||||
unsigned int simpleApplication:1;
|
||||
} aflags;
|
||||
|
||||
WMOpenPanel *sharedOpenPanel;
|
||||
@@ -296,7 +296,7 @@ typedef struct W_Screen {
|
||||
struct W_Pixmap *altUnmountIcon;
|
||||
|
||||
struct W_Pixmap *magnifyIcon;
|
||||
/* struct W_Pixmap *altMagnifyIcon;*/
|
||||
/*struct W_Pixmap *altMagnifyIcon;*/
|
||||
struct W_Pixmap *wheelIcon;
|
||||
struct W_Pixmap *grayIcon;
|
||||
struct W_Pixmap *rgbIcon;
|
||||
@@ -364,7 +364,7 @@ typedef struct W_ViewDelegate {
|
||||
void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
|
||||
|
||||
void (*willResize)(struct W_ViewDelegate*, WMView*,
|
||||
unsigned int*, unsigned int*);
|
||||
unsigned int*, unsigned int*);
|
||||
} W_ViewDelegate;
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ typedef struct W_View {
|
||||
struct W_Screen *screen;
|
||||
|
||||
WMWidget *self; /* must point to the widget the
|
||||
* view belongs to */
|
||||
* view belongs to */
|
||||
|
||||
W_ViewDelegate *delegate;
|
||||
|
||||
@@ -553,8 +553,8 @@ void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
|
||||
WMImagePosition position, WMColor *backColor, int ofs);
|
||||
|
||||
void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
|
||||
int width, WMAlignment alignment, WMColor *color,
|
||||
int wrap, char *text, int length);
|
||||
int width, WMAlignment alignment, WMColor *color,
|
||||
int wrap, char *text, int length);
|
||||
|
||||
int W_GetTextHeight(WMFont *font, char *text, int width, int wrap);
|
||||
|
||||
@@ -649,3 +649,4 @@ void W_FreeViewXdndPart(WMView *view);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _WINGSP_H_ */
|
||||
|
||||
+54
-54
@@ -47,18 +47,18 @@
|
||||
#else /* !DEBUG */
|
||||
|
||||
#define wassertr(expr) \
|
||||
if (!(expr)) { \
|
||||
wwarning("%s line %i (%s): assertion %s failed",\
|
||||
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
|
||||
return;\
|
||||
}
|
||||
if (!(expr)) { \
|
||||
wwarning("%s line %i (%s): assertion %s failed",\
|
||||
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
|
||||
return;\
|
||||
}
|
||||
|
||||
#define wassertrv(expr, val) \
|
||||
if (!(expr)) { \
|
||||
wwarning("%s line %i (%s): assertion %s failed",\
|
||||
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
|
||||
return (val);\
|
||||
}
|
||||
if (!(expr)) { \
|
||||
wwarning("%s line %i (%s): assertion %s failed",\
|
||||
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
|
||||
return (val);\
|
||||
}
|
||||
#endif /* !DEBUG */
|
||||
|
||||
#endif /* !NDEBUG */
|
||||
@@ -71,15 +71,15 @@ extern "C" {
|
||||
|
||||
typedef enum {
|
||||
WMPostWhenIdle = 1,
|
||||
WMPostASAP = 2,
|
||||
WMPostNow = 3
|
||||
WMPostASAP = 2,
|
||||
WMPostNow = 3
|
||||
} WMPostingStyle;
|
||||
|
||||
|
||||
typedef enum {
|
||||
WNCNone = 0,
|
||||
WNCOnName = 1,
|
||||
WNCOnSender = 2
|
||||
WNCOnName = 1,
|
||||
WNCOnSender = 2
|
||||
} WMNotificationCoalescing;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ typedef struct {
|
||||
/* NULL does nothing */
|
||||
void* (*retainKey)(const void *);
|
||||
/* NULL does nothing */
|
||||
void (*releaseKey)(const void *);
|
||||
void (*releaseKey)(const void *);
|
||||
} WMHashTableCallbacks;
|
||||
|
||||
|
||||
@@ -201,8 +201,8 @@ typedef struct ConnectionDelegate {
|
||||
} ConnectionDelegate;
|
||||
|
||||
|
||||
typedef void WMNotificationObserverAction(void *observerData,
|
||||
WMNotification *notification);
|
||||
typedef void WMNotificationObserverAction(void *observerData,
|
||||
WMNotification *notification);
|
||||
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ void wusleep(unsigned int microsec);
|
||||
|
||||
#if 0
|
||||
int wsprintesc(char *buffer, int length, char *format, WMSEscapes **escapes,
|
||||
int count);
|
||||
int count);
|
||||
#endif
|
||||
|
||||
/*......................................................................*/
|
||||
@@ -293,7 +293,7 @@ int wsprintesc(char *buffer, int length, char *format, WMSEscapes **escapes,
|
||||
/* Event handlers: timer, idle, input */
|
||||
|
||||
WMHandlerID WMAddTimerHandler(int milliseconds, WMCallback *callback,
|
||||
void *cdata);
|
||||
void *cdata);
|
||||
|
||||
WMHandlerID WMAddPersistentTimerHandler(int milliseconds, WMCallback *callback,
|
||||
void *cdata);
|
||||
@@ -306,8 +306,8 @@ WMHandlerID WMAddIdleHandler(WMCallback *callback, void *cdata);
|
||||
|
||||
void WMDeleteIdleHandler(WMHandlerID handlerID);
|
||||
|
||||
WMHandlerID WMAddInputHandler(int fd, int condition, WMInputProc *proc,
|
||||
void *clientData);
|
||||
WMHandlerID WMAddInputHandler(int fd, int condition, WMInputProc *proc,
|
||||
void *clientData);
|
||||
|
||||
void WMDeleteInputHandler(WMHandlerID handlerID);
|
||||
|
||||
@@ -373,7 +373,7 @@ extern const WMHashTableCallbacks WMIntHashCallbacks;
|
||||
/* sizeof(keys) are <= sizeof(void*) */
|
||||
|
||||
extern const WMHashTableCallbacks WMStringHashCallbacks;
|
||||
/* keys are strings. Strings will be copied with wstrdup()
|
||||
/* keys are strings. Strings will be copied with wstrdup()
|
||||
* and freed with wfree() */
|
||||
|
||||
extern const WMHashTableCallbacks WMStringPointerHashCallbacks;
|
||||
@@ -392,7 +392,7 @@ extern const WMHashTableCallbacks WMStringPointerHashCallbacks;
|
||||
* Fast [O(1)] push/pop
|
||||
*
|
||||
* Cons:
|
||||
* A little slower [O(n)] for insertion/deletion of elements that
|
||||
* A little slower [O(n)] for insertion/deletion of elements that
|
||||
* aren't in the end
|
||||
*/
|
||||
|
||||
@@ -475,23 +475,23 @@ void* WMArrayPrevious(WMArray *array, WMArrayIterator *iter);
|
||||
|
||||
/* The following 2 macros assume that the array doesn't change in the for loop */
|
||||
#define WM_ITERATE_ARRAY(array, var, i) \
|
||||
for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
|
||||
var = WMArrayNext(array, &(i)))
|
||||
for (var = WMArrayFirst(array, &(i)); (i) != WANotFound; \
|
||||
var = WMArrayNext(array, &(i)))
|
||||
|
||||
#define WM_ETARETI_ARRAY(array, var, i) \
|
||||
for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
|
||||
var = WMArrayPrevious(array, &(i)))
|
||||
for (var = WMArrayLast(array, &(i)); (i) != WANotFound; \
|
||||
var = WMArrayPrevious(array, &(i)))
|
||||
|
||||
/*..........................................................................*/
|
||||
|
||||
/*
|
||||
* Tree bags use a red-black tree for storage.
|
||||
* Item indexes may be any integer number.
|
||||
*
|
||||
*
|
||||
* Pros:
|
||||
* O(lg n) insertion/deletion/search
|
||||
* Good for large numbers of elements with sparse indexes
|
||||
*
|
||||
*
|
||||
* Cons:
|
||||
* O(lg n) insertion/deletion/search
|
||||
* Slow for storing small numbers of elements
|
||||
@@ -565,12 +565,12 @@ int WMBagIndexForIterator(WMBag *bag, WMBagIterator ptr);
|
||||
|
||||
/* The following 2 macros assume that the bag doesn't change in the for loop */
|
||||
#define WM_ITERATE_BAG(bag, var, i) \
|
||||
for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
|
||||
var = WMBagNext(bag, &(i)))
|
||||
for (var = WMBagFirst(bag, &(i)); (i) != NULL; \
|
||||
var = WMBagNext(bag, &(i)))
|
||||
|
||||
#define WM_ETARETI_BAG(bag, var, i) \
|
||||
for (var = WMBagLast(bag, &(i)); (i) != NULL; \
|
||||
var = WMBagPrevious(bag, &(i)))
|
||||
for (var = WMBagLast(bag, &(i)); (i) != NULL; \
|
||||
var = WMBagPrevious(bag, &(i)))
|
||||
|
||||
|
||||
|
||||
@@ -703,15 +703,15 @@ void* WMGetNotificationObject(WMNotification *notification);
|
||||
const char* WMGetNotificationName(WMNotification *notification);
|
||||
|
||||
|
||||
void WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
void *observer, const char *name, void *object);
|
||||
void WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
void *observer, const char *name, void *object);
|
||||
|
||||
void WMPostNotification(WMNotification *notification);
|
||||
|
||||
void WMRemoveNotificationObserver(void *observer);
|
||||
|
||||
void WMRemoveNotificationObserverWithName(void *observer, const char *name,
|
||||
void *object);
|
||||
void WMRemoveNotificationObserverWithName(void *observer, const char *name,
|
||||
void *object);
|
||||
|
||||
void WMPostNotificationName(const char *name, void *object, void *clientData);
|
||||
|
||||
@@ -719,18 +719,18 @@ WMNotificationQueue* WMGetDefaultNotificationQueue(void);
|
||||
|
||||
WMNotificationQueue* WMCreateNotificationQueue(void);
|
||||
|
||||
void WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
unsigned mask);
|
||||
void WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
unsigned mask);
|
||||
|
||||
void WMEnqueueNotification(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
WMPostingStyle postingStyle);
|
||||
WMNotification *notification,
|
||||
WMPostingStyle postingStyle);
|
||||
|
||||
void WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
WMPostingStyle postingStyle,
|
||||
unsigned coalesceMask);
|
||||
void WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
WMPostingStyle postingStyle,
|
||||
unsigned coalesceMask);
|
||||
|
||||
|
||||
/*......................................................................*/
|
||||
@@ -855,7 +855,7 @@ WMPropList* WMGetUDKeys(WMUserDefaults *database);
|
||||
WMPropList* WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName);
|
||||
|
||||
void WMSetUDObjectForKey(WMUserDefaults *database, WMPropList *object,
|
||||
char *defaultName);
|
||||
char *defaultName);
|
||||
|
||||
void WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName);
|
||||
|
||||
@@ -867,17 +867,17 @@ float WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName);
|
||||
|
||||
Bool WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName);
|
||||
|
||||
void WMSetUDStringForKey(WMUserDefaults *database, char *value,
|
||||
char *defaultName);
|
||||
void WMSetUDStringForKey(WMUserDefaults *database, char *value,
|
||||
char *defaultName);
|
||||
|
||||
void WMSetUDIntegerForKey(WMUserDefaults *database, int value,
|
||||
char *defaultName);
|
||||
void WMSetUDIntegerForKey(WMUserDefaults *database, int value,
|
||||
char *defaultName);
|
||||
|
||||
void WMSetUDFloatForKey(WMUserDefaults *database, float value,
|
||||
char *defaultName);
|
||||
void WMSetUDFloatForKey(WMUserDefaults *database, float value,
|
||||
char *defaultName);
|
||||
|
||||
void WMSetUDBoolForKey(WMUserDefaults *database, Bool value,
|
||||
char *defaultName);
|
||||
char *defaultName);
|
||||
|
||||
WMPropList* WMGetUDSearchList(WMUserDefaults *database);
|
||||
|
||||
|
||||
+10
-8
@@ -65,11 +65,13 @@
|
||||
#endif
|
||||
|
||||
/* Stuff for setting the sockets into non-blocking mode. */
|
||||
/*#ifdef __POSIX_SOURCE
|
||||
/*
|
||||
#ifdef __POSIX_SOURCE
|
||||
# define NONBLOCK_OPT O_NONBLOCK
|
||||
#else
|
||||
# define NONBLOCK_OPT FNDELAY
|
||||
#endif*/
|
||||
#endif
|
||||
*/
|
||||
|
||||
#define NONBLOCK_OPT O_NONBLOCK
|
||||
|
||||
@@ -328,7 +330,7 @@ getSocketAddress(char* name, char* service, char* protocol)
|
||||
#ifndef HAVE_INET_ATON
|
||||
if ((socketaddr.sin_addr.s_addr = inet_addr(name)) == INADDR_NONE) {
|
||||
#else
|
||||
if (inet_aton(name, &socketaddr.sin_addr) == 0) {
|
||||
if (inet_aton(name, &socketaddr.sin_addr) == 0) {
|
||||
#endif
|
||||
WMReleaseHost(host);
|
||||
return NULL;
|
||||
@@ -419,8 +421,8 @@ WMCreateConnectionWithSocket(int sock, Bool closeOnRelease)
|
||||
cPtr->isNonBlocking = cPtr->wasNonBlocking;
|
||||
|
||||
/* some way to find out if it is connected, and binded. can't find
|
||||
if it listens though!!!
|
||||
*/
|
||||
if it listens though!!!
|
||||
*/
|
||||
|
||||
size = sizeof(clientname);
|
||||
n = getpeername(sock, (struct sockaddr*) &clientname, &size);
|
||||
@@ -830,9 +832,9 @@ WMSendConnectionData(WMConnection *cPtr, WMData *data)
|
||||
tPtr->handler = NULL;
|
||||
}
|
||||
/*if (cPtr->handler.write) {
|
||||
WMDeleteInputHandler(cPtr->handler.write);
|
||||
cPtr->handler.write = NULL;
|
||||
}*/
|
||||
WMDeleteInputHandler(cPtr->handler.write);
|
||||
cPtr->handler.write = NULL;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (cPtr->handler.write) {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* WINGs WMData function library
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1999-2003 Dan Pascu
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
|
||||
@@ -272,3 +272,4 @@ W_FreeViewXdndPart(WMView *view)
|
||||
if (view->dragImage)
|
||||
WMReleasePixmap(view->dragImage);
|
||||
}
|
||||
|
||||
+17
-17
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Window Maker miscelaneous function library
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1997-2003 Alfredo K. Kojima
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -64,7 +64,7 @@ wstrerror(int errnum)
|
||||
|
||||
/*********************************************************************
|
||||
* Prints a message with variable arguments
|
||||
*
|
||||
*
|
||||
* msg - message to print with optional formatting
|
||||
* ... - arguments to use on formatting
|
||||
*********************************************************************/
|
||||
@@ -90,19 +90,19 @@ wmessage(const char *msg, ...)
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* Prints a warning message with variable arguments
|
||||
*
|
||||
* Prints a warning message with variable arguments
|
||||
*
|
||||
* msg - message to print with optional formatting
|
||||
* ... - arguments to use on formatting
|
||||
*********************************************************************/
|
||||
void
|
||||
void
|
||||
wwarning(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[MAXLINE];
|
||||
|
||||
|
||||
va_start(args, msg);
|
||||
|
||||
|
||||
vsnprintf(buf, MAXLINE-3, msg, args);
|
||||
strcat(buf,"\n");
|
||||
fflush(stdout);
|
||||
@@ -111,18 +111,18 @@ wwarning(const char *msg, ...)
|
||||
fputs(buf, stderr);
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Prints a fatal error message with variable arguments and terminates
|
||||
*
|
||||
*
|
||||
* msg - message to print with optional formatting
|
||||
* ... - arguments to use on formatting
|
||||
* ... - arguments to use on formatting
|
||||
**************************************************************************/
|
||||
void
|
||||
void
|
||||
wfatal(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -144,12 +144,12 @@ wfatal(const char *msg, ...)
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* Prints a system error message with variable arguments
|
||||
*
|
||||
* Prints a system error message with variable arguments
|
||||
*
|
||||
* msg - message to print with optional formatting
|
||||
* ... - arguments to use on formatting
|
||||
*********************************************************************/
|
||||
void
|
||||
void
|
||||
wsyserror(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -174,12 +174,12 @@ wsyserror(const char *msg, ...)
|
||||
/*********************************************************************
|
||||
* Prints a system error message with variable arguments, being given
|
||||
* the error code.
|
||||
*
|
||||
*
|
||||
* error - the error code foe which to print the message
|
||||
* msg - message to print with optional formatting
|
||||
* ... - arguments to use on formatting
|
||||
*********************************************************************/
|
||||
void
|
||||
void
|
||||
wsyserrorwithcode(int error, const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
+167
-167
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Window Maker miscelaneous function library
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1997-2003 Alfredo K. Kojima
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -41,17 +41,17 @@ wgethomedir()
|
||||
struct passwd *user;
|
||||
|
||||
if (home)
|
||||
return home;
|
||||
|
||||
return home;
|
||||
|
||||
user = getpwuid(getuid());
|
||||
if (!user) {
|
||||
wsyserror(_("could not get password entry for UID %i"), getuid());
|
||||
return "/";
|
||||
wsyserror(_("could not get password entry for UID %i"), getuid());
|
||||
return "/";
|
||||
}
|
||||
if (!user->pw_dir) {
|
||||
return "/";
|
||||
return "/";
|
||||
} else {
|
||||
return user->pw_dir;
|
||||
return user->pw_dir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,16 +60,16 @@ static char*
|
||||
getuserhomedir(char *username)
|
||||
{
|
||||
struct passwd *user;
|
||||
|
||||
|
||||
user = getpwnam(username);
|
||||
if (!user) {
|
||||
wsyserror(_("could not get password entry for user %s"), username);
|
||||
return NULL;
|
||||
wsyserror(_("could not get password entry for user %s"), username);
|
||||
return NULL;
|
||||
}
|
||||
if (!user->pw_dir) {
|
||||
return "/";
|
||||
return "/";
|
||||
} else {
|
||||
return user->pw_dir;
|
||||
return user->pw_dir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,78 +84,78 @@ wexpandpath(char *path)
|
||||
int i;
|
||||
|
||||
memset(buffer, 0, PATH_MAX+2);
|
||||
|
||||
|
||||
if (*path=='~') {
|
||||
char *home;
|
||||
|
||||
path++;
|
||||
if (*path=='/' || *path==0) {
|
||||
home = wgethomedir();
|
||||
strcat(buffer, home);
|
||||
} else {
|
||||
int j;
|
||||
j = 0;
|
||||
while (*path!=0 && *path!='/') {
|
||||
buffer2[j++] = *path;
|
||||
buffer2[j] = 0;
|
||||
path++;
|
||||
}
|
||||
home = getuserhomedir(buffer2);
|
||||
if (!home)
|
||||
return NULL;
|
||||
strcat(buffer, home);
|
||||
}
|
||||
char *home;
|
||||
|
||||
path++;
|
||||
if (*path=='/' || *path==0) {
|
||||
home = wgethomedir();
|
||||
strcat(buffer, home);
|
||||
} else {
|
||||
int j;
|
||||
j = 0;
|
||||
while (*path!=0 && *path!='/') {
|
||||
buffer2[j++] = *path;
|
||||
buffer2[j] = 0;
|
||||
path++;
|
||||
}
|
||||
home = getuserhomedir(buffer2);
|
||||
if (!home)
|
||||
return NULL;
|
||||
strcat(buffer, home);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
i = strlen(buffer);
|
||||
|
||||
while (*path!=0) {
|
||||
char *tmp;
|
||||
|
||||
if (*path=='$') {
|
||||
int j = 0;
|
||||
path++;
|
||||
/* expand $(HOME) or $HOME style environment variables */
|
||||
if (*path=='(') {
|
||||
path++;
|
||||
while (*path!=0 && *path!=')') {
|
||||
buffer2[j++] = *(path++);
|
||||
buffer2[j] = 0;
|
||||
char *tmp;
|
||||
|
||||
if (*path=='$') {
|
||||
int j = 0;
|
||||
path++;
|
||||
/* expand $(HOME) or $HOME style environment variables */
|
||||
if (*path=='(') {
|
||||
path++;
|
||||
while (*path!=0 && *path!=')') {
|
||||
buffer2[j++] = *(path++);
|
||||
buffer2[j] = 0;
|
||||
}
|
||||
if (*path==')')
|
||||
path++;
|
||||
tmp = getenv(buffer2);
|
||||
if (!tmp) {
|
||||
buffer[i] = 0;
|
||||
strcat(buffer, "$(");
|
||||
strcat(buffer, buffer2);
|
||||
strcat(buffer, ")");
|
||||
i += strlen(buffer2)+3;
|
||||
} else {
|
||||
strcat(buffer, tmp);
|
||||
i += strlen(tmp);
|
||||
}
|
||||
} else {
|
||||
while (*path!=0 && *path!='/') {
|
||||
buffer2[j++] = *(path++);
|
||||
buffer2[j] = 0;
|
||||
}
|
||||
tmp = getenv(buffer2);
|
||||
if (!tmp) {
|
||||
strcat(buffer, "$");
|
||||
strcat(buffer, buffer2);
|
||||
i += strlen(buffer2)+1;
|
||||
} else {
|
||||
strcat(buffer, tmp);
|
||||
i += strlen(tmp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buffer[i++] = *path;
|
||||
path++;
|
||||
}
|
||||
tmp = getenv(buffer2);
|
||||
if (!tmp) {
|
||||
buffer[i] = 0;
|
||||
strcat(buffer, "$(");
|
||||
strcat(buffer, buffer2);
|
||||
strcat(buffer, ")");
|
||||
i += strlen(buffer2)+3;
|
||||
} else {
|
||||
strcat(buffer, tmp);
|
||||
i += strlen(tmp);
|
||||
}
|
||||
} else {
|
||||
while (*path!=0 && *path!='/') {
|
||||
buffer2[j++] = *(path++);
|
||||
buffer2[j] = 0;
|
||||
}
|
||||
tmp = getenv(buffer2);
|
||||
if (!tmp) {
|
||||
strcat(buffer, "$");
|
||||
strcat(buffer, buffer2);
|
||||
i += strlen(buffer2)+1;
|
||||
} else {
|
||||
strcat(buffer, tmp);
|
||||
i += strlen(tmp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buffer[i++] = *path;
|
||||
path++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return wstrdup(buffer);
|
||||
}
|
||||
|
||||
@@ -185,17 +185,17 @@ nextchar(char *string, char tok)
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* findfile--
|
||||
* Finds a file in a : separated list of paths. ~ expansion is also
|
||||
* Finds a file in a : separated list of paths. ~ expansion is also
|
||||
* done.
|
||||
*
|
||||
*
|
||||
* Returns:
|
||||
* The complete path for the file (in a newly allocated string) or
|
||||
* NULL if the file was not found.
|
||||
*
|
||||
*
|
||||
* Side effects:
|
||||
* A new string is allocated. It must be freed later.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
char*
|
||||
wfindfile(char *paths, char *file)
|
||||
@@ -206,23 +206,23 @@ wfindfile(char *paths, char *file)
|
||||
char *fullpath;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
if (*file=='/' || *file=='~' || *file=='$' || !paths || *paths==0) {
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
return NULL;
|
||||
|
||||
if (access(fullpath, F_OK)<0) {
|
||||
wfree(fullpath);
|
||||
return NULL;
|
||||
} else {
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
}
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
return NULL;
|
||||
|
||||
if (access(fullpath, F_OK)<0) {
|
||||
wfree(fullpath);
|
||||
return NULL;
|
||||
} else {
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
}
|
||||
}
|
||||
|
||||
flen = strlen(file);
|
||||
@@ -263,43 +263,43 @@ wfindfileinlist(char **path_list, char *file)
|
||||
char *fullpath;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
if (*file=='/' || *file=='~' || !path_list) {
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
return NULL;
|
||||
|
||||
if (access(fullpath, F_OK)<0) {
|
||||
wfree(fullpath);
|
||||
return NULL;
|
||||
} else {
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
}
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
return NULL;
|
||||
|
||||
if (access(fullpath, F_OK)<0) {
|
||||
wfree(fullpath);
|
||||
return NULL;
|
||||
} else {
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
}
|
||||
}
|
||||
|
||||
flen = strlen(file);
|
||||
for (i=0; path_list[i]!=NULL; i++) {
|
||||
len = strlen(path_list[i]);
|
||||
path = wmalloc(len+flen+2);
|
||||
path = memcpy(path, path_list[i], len);
|
||||
path[len]=0;
|
||||
strcat(path, "/");
|
||||
strcat(path, file);
|
||||
/* expand tilde */
|
||||
fullpath = wexpandpath(path);
|
||||
wfree(path);
|
||||
if (fullpath) {
|
||||
/* check if file exists */
|
||||
if (access(fullpath, F_OK)==0) {
|
||||
return fullpath;
|
||||
}
|
||||
wfree(fullpath);
|
||||
}
|
||||
len = strlen(path_list[i]);
|
||||
path = wmalloc(len+flen+2);
|
||||
path = memcpy(path, path_list[i], len);
|
||||
path[len]=0;
|
||||
strcat(path, "/");
|
||||
strcat(path, file);
|
||||
/* expand tilde */
|
||||
fullpath = wexpandpath(path);
|
||||
wfree(path);
|
||||
if (fullpath) {
|
||||
/* check if file exists */
|
||||
if (access(fullpath, F_OK)==0) {
|
||||
return fullpath;
|
||||
}
|
||||
wfree(fullpath);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -315,51 +315,51 @@ wfindfileinarray(WMPropList *array, char *file)
|
||||
char *fullpath;
|
||||
|
||||
if (!file)
|
||||
return NULL;
|
||||
|
||||
if (*file=='/' || *file=='~' || !array) {
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (access(fullpath, F_OK)<0) {
|
||||
wfree(fullpath);
|
||||
return NULL;
|
||||
} else {
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
}
|
||||
if (*file=='/' || *file=='~' || !array) {
|
||||
if (access(file, F_OK)<0) {
|
||||
fullpath = wexpandpath(file);
|
||||
if (!fullpath)
|
||||
return NULL;
|
||||
|
||||
if (access(fullpath, F_OK)<0) {
|
||||
wfree(fullpath);
|
||||
return NULL;
|
||||
} else {
|
||||
return fullpath;
|
||||
}
|
||||
} else {
|
||||
return wstrdup(file);
|
||||
}
|
||||
}
|
||||
|
||||
flen = strlen(file);
|
||||
for (i=0; i<WMGetPropListItemCount(array); i++) {
|
||||
WMPropList *prop;
|
||||
char *p;
|
||||
WMPropList *prop;
|
||||
char *p;
|
||||
|
||||
prop = WMGetFromPLArray(array, i);
|
||||
if (!prop)
|
||||
continue;
|
||||
p = WMGetFromPLString(prop);
|
||||
prop = WMGetFromPLArray(array, i);
|
||||
if (!prop)
|
||||
continue;
|
||||
p = WMGetFromPLString(prop);
|
||||
|
||||
len = strlen(p);
|
||||
path = wmalloc(len+flen+2);
|
||||
path = memcpy(path, p, len);
|
||||
path[len]=0;
|
||||
strcat(path, "/");
|
||||
strcat(path, file);
|
||||
/* expand tilde */
|
||||
fullpath = wexpandpath(path);
|
||||
wfree(path);
|
||||
if (fullpath) {
|
||||
/* check if file exists */
|
||||
if (access(fullpath, F_OK)==0) {
|
||||
return fullpath;
|
||||
}
|
||||
wfree(fullpath);
|
||||
}
|
||||
len = strlen(p);
|
||||
path = wmalloc(len+flen+2);
|
||||
path = memcpy(path, p, len);
|
||||
path[len]=0;
|
||||
strcat(path, "/");
|
||||
strcat(path, file);
|
||||
/* expand tilde */
|
||||
fullpath = wexpandpath(path);
|
||||
wfree(path);
|
||||
if (fullpath) {
|
||||
/* check if file exists */
|
||||
if (access(fullpath, F_OK)==0) {
|
||||
return fullpath;
|
||||
}
|
||||
wfree(fullpath);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+63
-62
@@ -60,14 +60,15 @@ static WMArray *inputHandler=NULL;
|
||||
|
||||
|
||||
static void
|
||||
rightNow(struct timeval *tv) {
|
||||
rightNow(struct timeval *tv)
|
||||
{
|
||||
X_GETTIMEOFDAY(tv);
|
||||
}
|
||||
|
||||
/* is t1 after t2 ? */
|
||||
#define IS_AFTER(t1, t2) (((t1).tv_sec > (t2).tv_sec) || \
|
||||
(((t1).tv_sec == (t2).tv_sec) \
|
||||
&& ((t1).tv_usec > (t2).tv_usec)))
|
||||
(((t1).tv_sec == (t2).tv_sec) \
|
||||
&& ((t1).tv_usec > (t2).tv_usec)))
|
||||
|
||||
#define IS_ZERO(tv) (tv.tv_sec == 0 && tv.tv_usec == 0)
|
||||
|
||||
@@ -90,16 +91,16 @@ enqueueTimerHandler(TimerHandler *handler)
|
||||
|
||||
/* insert callback in queue, sorted by time left */
|
||||
if (!timerHandler || !IS_AFTER(handler->when, timerHandler->when)) {
|
||||
/* first in the queue */
|
||||
handler->next = timerHandler;
|
||||
timerHandler = handler;
|
||||
/* first in the queue */
|
||||
handler->next = timerHandler;
|
||||
timerHandler = handler;
|
||||
} else {
|
||||
tmp = timerHandler;
|
||||
while (tmp->next && IS_AFTER(handler->when, tmp->next->when)) {
|
||||
tmp = tmp->next;
|
||||
}
|
||||
handler->next = tmp->next;
|
||||
tmp->next = handler;
|
||||
tmp = timerHandler;
|
||||
while (tmp->next && IS_AFTER(handler->when, tmp->next->when)) {
|
||||
tmp = tmp->next;
|
||||
}
|
||||
handler->next = tmp->next;
|
||||
tmp->next = handler;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,22 +117,22 @@ delayUntilNextTimerEvent(struct timeval *delay)
|
||||
if (!handler) {
|
||||
/* The return value of this function is only valid if there _are_
|
||||
timers active. */
|
||||
delay->tv_sec = 0;
|
||||
delay->tv_usec = 0;
|
||||
return;
|
||||
delay->tv_sec = 0;
|
||||
delay->tv_usec = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
rightNow(&now);
|
||||
if (IS_AFTER(now, handler->when)) {
|
||||
delay->tv_sec = 0;
|
||||
delay->tv_usec = 0;
|
||||
delay->tv_sec = 0;
|
||||
delay->tv_usec = 0;
|
||||
} else {
|
||||
delay->tv_sec = handler->when.tv_sec - now.tv_sec;
|
||||
delay->tv_usec = handler->when.tv_usec - now.tv_usec;
|
||||
if (delay->tv_usec < 0) {
|
||||
delay->tv_usec += 1000000;
|
||||
delay->tv_sec--;
|
||||
}
|
||||
delay->tv_sec = handler->when.tv_sec - now.tv_sec;
|
||||
delay->tv_usec = handler->when.tv_usec - now.tv_usec;
|
||||
if (delay->tv_usec < 0) {
|
||||
delay->tv_usec += 1000000;
|
||||
delay->tv_sec--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +144,7 @@ WMAddTimerHandler(int milliseconds, WMCallback *callback, void *cdata)
|
||||
|
||||
handler = malloc(sizeof(TimerHandler));
|
||||
if (!handler)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
rightNow(&handler->when);
|
||||
addmillisecs(&handler->when, milliseconds);
|
||||
@@ -163,7 +164,7 @@ WMAddPersistentTimerHandler(int milliseconds, WMCallback *callback, void *cdata)
|
||||
TimerHandler *handler = WMAddTimerHandler(milliseconds, callback, cdata);
|
||||
|
||||
if (handler != NULL)
|
||||
handler->nextDelay = milliseconds;
|
||||
handler->nextDelay = milliseconds;
|
||||
|
||||
return handler;
|
||||
}
|
||||
@@ -180,18 +181,18 @@ WMDeleteTimerWithClientData(void *cdata)
|
||||
|
||||
tmp = timerHandler;
|
||||
if (tmp->clientData==cdata) {
|
||||
tmp->nextDelay = 0;
|
||||
if (!IS_ZERO(tmp->when)) {
|
||||
timerHandler = tmp->next;
|
||||
wfree(tmp);
|
||||
}
|
||||
tmp->nextDelay = 0;
|
||||
if (!IS_ZERO(tmp->when)) {
|
||||
timerHandler = tmp->next;
|
||||
wfree(tmp);
|
||||
}
|
||||
} else {
|
||||
while (tmp->next) {
|
||||
if (tmp->next->clientData==cdata) {
|
||||
handler = tmp->next;
|
||||
handler->nextDelay = 0;
|
||||
if (IS_ZERO(handler->when))
|
||||
break;
|
||||
handler->nextDelay = 0;
|
||||
if (IS_ZERO(handler->when))
|
||||
break;
|
||||
tmp->next = handler->next;
|
||||
wfree(handler);
|
||||
break;
|
||||
@@ -209,27 +210,27 @@ WMDeleteTimerHandler(WMHandlerID handlerID)
|
||||
TimerHandler *tmp, *handler=(TimerHandler*)handlerID;
|
||||
|
||||
if (!handler || !timerHandler)
|
||||
return;
|
||||
return;
|
||||
|
||||
tmp = timerHandler;
|
||||
|
||||
handler->nextDelay = 0;
|
||||
|
||||
if (IS_ZERO(handler->when))
|
||||
return;
|
||||
return;
|
||||
|
||||
if (tmp==handler) {
|
||||
timerHandler = handler->next;
|
||||
wfree(handler);
|
||||
timerHandler = handler->next;
|
||||
wfree(handler);
|
||||
} else {
|
||||
while (tmp->next) {
|
||||
if (tmp->next==handler) {
|
||||
tmp->next=handler->next;
|
||||
wfree(handler);
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
while (tmp->next) {
|
||||
if (tmp->next==handler) {
|
||||
tmp->next=handler->next;
|
||||
wfree(handler);
|
||||
break;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +297,7 @@ WMDeleteInputHandler(WMHandlerID handlerID)
|
||||
InputHandler *handler = (InputHandler*)handlerID;
|
||||
|
||||
if (!handler || !inputHandler)
|
||||
return;
|
||||
return;
|
||||
|
||||
WMRemoveFromArray(inputHandler, handler);
|
||||
}
|
||||
@@ -310,7 +311,7 @@ W_CheckIdleHandlers(void)
|
||||
WMArrayIterator iter;
|
||||
|
||||
if (!idleHandler || WMGetArrayItemCount(idleHandler)==0) {
|
||||
W_FlushIdleNotificationQueue();
|
||||
W_FlushIdleNotificationQueue();
|
||||
/* make sure an observer in queue didn't added an idle handler */
|
||||
return (idleHandler!=NULL && WMGetArrayItemCount(idleHandler)>0);
|
||||
}
|
||||
@@ -322,7 +323,7 @@ W_CheckIdleHandlers(void)
|
||||
if (WMGetFirstInArray(idleHandler, handler) == WANotFound)
|
||||
continue;
|
||||
|
||||
(*handler->callback)(handler->clientData);
|
||||
(*handler->callback)(handler->clientData);
|
||||
WMDeleteIdleHandler(handler);
|
||||
}
|
||||
|
||||
@@ -351,24 +352,24 @@ W_CheckTimerHandlers(void)
|
||||
|
||||
handler = timerHandler;
|
||||
while (handler && IS_AFTER(now, handler->when)) {
|
||||
if (!IS_ZERO(handler->when)) {
|
||||
SET_ZERO(handler->when);
|
||||
(*handler->callback)(handler->clientData);
|
||||
}
|
||||
handler = handler->next;
|
||||
if (!IS_ZERO(handler->when)) {
|
||||
SET_ZERO(handler->when);
|
||||
(*handler->callback)(handler->clientData);
|
||||
}
|
||||
handler = handler->next;
|
||||
}
|
||||
|
||||
while (timerHandler && IS_ZERO(timerHandler->when)) {
|
||||
handler = timerHandler;
|
||||
timerHandler = timerHandler->next;
|
||||
handler = timerHandler;
|
||||
timerHandler = timerHandler->next;
|
||||
|
||||
if (handler->nextDelay > 0) {
|
||||
handler->when = now;
|
||||
addmillisecs(&handler->when, handler->nextDelay);
|
||||
enqueueTimerHandler(handler);
|
||||
} else {
|
||||
wfree(handler);
|
||||
}
|
||||
if (handler->nextDelay > 0) {
|
||||
handler->when = now;
|
||||
addmillisecs(&handler->when, handler->nextDelay);
|
||||
enqueueTimerHandler(handler);
|
||||
} else {
|
||||
wfree(handler);
|
||||
}
|
||||
}
|
||||
|
||||
W_FlushASAPNotificationQueue();
|
||||
|
||||
+139
-139
@@ -23,7 +23,7 @@
|
||||
typedef struct HashItem {
|
||||
const void *key;
|
||||
const void *data;
|
||||
|
||||
|
||||
struct HashItem *next; /* collided item list */
|
||||
} HashItem;
|
||||
|
||||
@@ -41,13 +41,13 @@ typedef struct W_HashTable {
|
||||
|
||||
|
||||
#define HASH(table, key) (((table)->callbacks.hash ? \
|
||||
(*(table)->callbacks.hash)(key) : hashPtr(key)) % (table)->size)
|
||||
(*(table)->callbacks.hash)(key) : hashPtr(key)) % (table)->size)
|
||||
|
||||
#define DUPKEY(table, key) ((table)->callbacks.retainKey ? \
|
||||
(*(table)->callbacks.retainKey)(key) : (key))
|
||||
(*(table)->callbacks.retainKey)(key) : (key))
|
||||
|
||||
#define RELKEY(table, key) if ((table)->callbacks.releaseKey) \
|
||||
(*(table)->callbacks.releaseKey)(key)
|
||||
(*(table)->callbacks.releaseKey)(key)
|
||||
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ hashString(const char *key)
|
||||
unsigned ctr = 0;
|
||||
|
||||
while (*key) {
|
||||
ret ^= *(char*)key++ << ctr;
|
||||
ctr = (ctr + 1) % sizeof (char *);
|
||||
ret ^= *(char*)key++ << ctr;
|
||||
ctr = (ctr + 1) % sizeof (char *);
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -106,13 +106,13 @@ rebuildTable(WMHashTable *table)
|
||||
table->table = wmalloc(sizeof(char*)*newSize);
|
||||
memset(table->table, 0, sizeof(char*)*newSize);
|
||||
table->size = newSize;
|
||||
|
||||
|
||||
for (i = 0; i < oldSize; i++) {
|
||||
while (oldArray[i]!=NULL) {
|
||||
next = oldArray[i]->next;
|
||||
rellocateItem(table, oldArray[i]);
|
||||
oldArray[i] = next;
|
||||
}
|
||||
while (oldArray[i]!=NULL) {
|
||||
next = oldArray[i]->next;
|
||||
rellocateItem(table, oldArray[i]);
|
||||
oldArray[i] = next;
|
||||
}
|
||||
}
|
||||
wfree(oldArray);
|
||||
}
|
||||
@@ -123,17 +123,17 @@ WMHashTable*
|
||||
WMCreateHashTable(WMHashTableCallbacks callbacks)
|
||||
{
|
||||
HashTable *table;
|
||||
|
||||
|
||||
table = wmalloc(sizeof(HashTable));
|
||||
memset(table, 0, sizeof(HashTable));
|
||||
|
||||
|
||||
table->callbacks = callbacks;
|
||||
|
||||
|
||||
table->size = INITIAL_CAPACITY;
|
||||
|
||||
table->table = wmalloc(sizeof(HashItem*)*table->size);
|
||||
memset(table->table, 0, sizeof(HashItem*)*table->size);
|
||||
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@@ -145,21 +145,21 @@ WMResetHashTable(WMHashTable *table)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < table->size; i++) {
|
||||
item = table->table[i];
|
||||
while (item) {
|
||||
tmp = item->next;
|
||||
RELKEY(table, item->key);
|
||||
wfree(item);
|
||||
item = tmp;
|
||||
}
|
||||
item = table->table[i];
|
||||
while (item) {
|
||||
tmp = item->next;
|
||||
RELKEY(table, item->key);
|
||||
wfree(item);
|
||||
item = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
table->itemCount = 0;
|
||||
|
||||
|
||||
if (table->size > INITIAL_CAPACITY) {
|
||||
wfree(table->table);
|
||||
table->size = INITIAL_CAPACITY;
|
||||
table->table = wmalloc(sizeof(HashItem*)*table->size);
|
||||
wfree(table->table);
|
||||
table->size = INITIAL_CAPACITY;
|
||||
table->table = wmalloc(sizeof(HashItem*)*table->size);
|
||||
}
|
||||
memset(table->table, 0, sizeof(HashItem*)*table->size);
|
||||
}
|
||||
@@ -170,15 +170,15 @@ WMFreeHashTable(WMHashTable *table)
|
||||
{
|
||||
HashItem *item, *tmp;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < table->size; i++) {
|
||||
item = table->table[i];
|
||||
while (item) {
|
||||
tmp = item->next;
|
||||
RELKEY(table, item->key);
|
||||
wfree(item);
|
||||
item = tmp;
|
||||
}
|
||||
item = table->table[i];
|
||||
while (item) {
|
||||
tmp = item->next;
|
||||
RELKEY(table, item->key);
|
||||
wfree(item);
|
||||
item = tmp;
|
||||
}
|
||||
}
|
||||
wfree(table->table);
|
||||
wfree(table);
|
||||
@@ -197,29 +197,29 @@ WMHashGet(WMHashTable *table, const void *key)
|
||||
{
|
||||
unsigned h;
|
||||
HashItem *item;
|
||||
|
||||
|
||||
h = HASH(table, key);
|
||||
item = table->table[h];
|
||||
|
||||
|
||||
if (table->callbacks.keyIsEqual) {
|
||||
while (item) {
|
||||
if ((*table->callbacks.keyIsEqual)(key, item->key)) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
while (item) {
|
||||
if ((*table->callbacks.keyIsEqual)(key, item->key)) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
} else {
|
||||
while (item) {
|
||||
if (key == item->key) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
while (item) {
|
||||
if (key == item->key) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
}
|
||||
if (item)
|
||||
return (void*)item->data;
|
||||
return (void*)item->data;
|
||||
else
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,31 +229,31 @@ WMHashGetItemAndKey(WMHashTable *table, const void *key,
|
||||
{
|
||||
unsigned h;
|
||||
HashItem *item;
|
||||
|
||||
|
||||
h = HASH(table, key);
|
||||
item = table->table[h];
|
||||
|
||||
|
||||
if (table->callbacks.keyIsEqual) {
|
||||
while (item) {
|
||||
if ((*table->callbacks.keyIsEqual)(key, item->key)) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
while (item) {
|
||||
if ((*table->callbacks.keyIsEqual)(key, item->key)) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
} else {
|
||||
while (item) {
|
||||
if (key == item->key) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
while (item) {
|
||||
if (key == item->key) {
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
}
|
||||
if (item) {
|
||||
if (retKey)
|
||||
*retKey = (void*)item->key;
|
||||
if (retItem)
|
||||
*retItem = (void*)item->data;
|
||||
return True;
|
||||
return True;
|
||||
} else {
|
||||
return False;
|
||||
}
|
||||
@@ -267,60 +267,60 @@ WMHashInsert(WMHashTable *table, const void *key, const void *data)
|
||||
unsigned h;
|
||||
HashItem *item;
|
||||
int replacing = 0;
|
||||
|
||||
|
||||
h = HASH(table, key);
|
||||
/* look for the entry */
|
||||
item = table->table[h];
|
||||
if (table->callbacks.keyIsEqual) {
|
||||
while (item) {
|
||||
if ((*table->callbacks.keyIsEqual)(key, item->key)) {
|
||||
replacing = 1;
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
while (item) {
|
||||
if ((*table->callbacks.keyIsEqual)(key, item->key)) {
|
||||
replacing = 1;
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
} else {
|
||||
while (item) {
|
||||
if (key == item->key) {
|
||||
replacing = 1;
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
while (item) {
|
||||
if (key == item->key) {
|
||||
replacing = 1;
|
||||
break;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (replacing) {
|
||||
const void *old;
|
||||
const void *old;
|
||||
|
||||
old = item->data;
|
||||
item->data = data;
|
||||
RELKEY(table, item->key);
|
||||
item->key = DUPKEY(table, key);
|
||||
old = item->data;
|
||||
item->data = data;
|
||||
RELKEY(table, item->key);
|
||||
item->key = DUPKEY(table, key);
|
||||
|
||||
return (void*)old;
|
||||
return (void*)old;
|
||||
} else {
|
||||
HashItem *nitem;
|
||||
HashItem *nitem;
|
||||
|
||||
nitem = wmalloc(sizeof(HashItem));
|
||||
nitem->key = DUPKEY(table, key);
|
||||
nitem->data = data;
|
||||
nitem->next = table->table[h];
|
||||
table->table[h] = nitem;
|
||||
nitem = wmalloc(sizeof(HashItem));
|
||||
nitem->key = DUPKEY(table, key);
|
||||
nitem->data = data;
|
||||
nitem->next = table->table[h];
|
||||
table->table[h] = nitem;
|
||||
|
||||
table->itemCount++;
|
||||
table->itemCount++;
|
||||
}
|
||||
|
||||
|
||||
/* OPTIMIZE: put this in an idle handler.*/
|
||||
if (table->itemCount > table->size) {
|
||||
#ifdef DEBUG0
|
||||
printf("rebuilding hash table...\n");
|
||||
printf("rebuilding hash table...\n");
|
||||
#endif
|
||||
rebuildTable(table);
|
||||
rebuildTable(table);
|
||||
#ifdef DEBUG0
|
||||
printf("finished rebuild.\n");
|
||||
printf("finished rebuild.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -329,23 +329,23 @@ static HashItem*
|
||||
deleteFromList(HashTable *table, HashItem *item, const void *key)
|
||||
{
|
||||
HashItem *next;
|
||||
|
||||
|
||||
if (item==NULL)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if ((table->callbacks.keyIsEqual
|
||||
&& (*table->callbacks.keyIsEqual)(key, item->key))
|
||||
|| (!table->callbacks.keyIsEqual && key==item->key)) {
|
||||
|
||||
next = item->next;
|
||||
RELKEY(table, item->key);
|
||||
wfree(item);
|
||||
|
||||
table->itemCount--;
|
||||
if ((table->callbacks.keyIsEqual
|
||||
&& (*table->callbacks.keyIsEqual)(key, item->key))
|
||||
|| (!table->callbacks.keyIsEqual && key==item->key)) {
|
||||
|
||||
return next;
|
||||
next = item->next;
|
||||
RELKEY(table, item->key);
|
||||
wfree(item);
|
||||
|
||||
table->itemCount--;
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
item->next = deleteFromList(table, item->next, key);
|
||||
|
||||
return item;
|
||||
@@ -356,9 +356,9 @@ void
|
||||
WMHashRemove(WMHashTable *table, const void *key)
|
||||
{
|
||||
unsigned h;
|
||||
|
||||
|
||||
h = HASH(table, key);
|
||||
|
||||
|
||||
table->table[h] = deleteFromList(table, table->table[h], key);
|
||||
}
|
||||
|
||||
@@ -367,11 +367,11 @@ WMHashEnumerator
|
||||
WMEnumerateHashTable(WMHashTable *table)
|
||||
{
|
||||
WMHashEnumerator enumerator;
|
||||
|
||||
|
||||
enumerator.table = table;
|
||||
enumerator.index = 0;
|
||||
enumerator.nextItem = table->table[0];
|
||||
|
||||
|
||||
return enumerator;
|
||||
}
|
||||
|
||||
@@ -382,24 +382,24 @@ WMNextHashEnumeratorItem(WMHashEnumerator *enumerator)
|
||||
{
|
||||
const void *data = NULL;
|
||||
|
||||
/* this assumes the table doesn't change between
|
||||
/* this assumes the table doesn't change between
|
||||
* WMEnumerateHashTable() and WMNextHashEnumeratorItem() calls */
|
||||
|
||||
if (enumerator->nextItem==NULL) {
|
||||
HashTable *table = enumerator->table;
|
||||
while (++enumerator->index < table->size) {
|
||||
if (table->table[enumerator->index]!=NULL) {
|
||||
enumerator->nextItem = table->table[enumerator->index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
HashTable *table = enumerator->table;
|
||||
while (++enumerator->index < table->size) {
|
||||
if (table->table[enumerator->index]!=NULL) {
|
||||
enumerator->nextItem = table->table[enumerator->index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (enumerator->nextItem) {
|
||||
data = ((HashItem*)enumerator->nextItem)->data;
|
||||
enumerator->nextItem = ((HashItem*)enumerator->nextItem)->next;
|
||||
data = ((HashItem*)enumerator->nextItem)->data;
|
||||
enumerator->nextItem = ((HashItem*)enumerator->nextItem)->next;
|
||||
}
|
||||
|
||||
|
||||
return (void*)data;
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ WMNextHashEnumeratorKey(WMHashEnumerator *enumerator)
|
||||
{
|
||||
const void *key = NULL;
|
||||
|
||||
/* this assumes the table doesn't change between
|
||||
/* this assumes the table doesn't change between
|
||||
* WMEnumerateHashTable() and WMNextHashEnumeratorKey() calls */
|
||||
|
||||
if (enumerator->nextItem==NULL) {
|
||||
@@ -435,17 +435,17 @@ Bool
|
||||
WMNextHashEnumeratorItemAndKey(WMHashEnumerator *enumerator,
|
||||
void **item, void **key)
|
||||
{
|
||||
/* this assumes the table doesn't change between
|
||||
/* this assumes the table doesn't change between
|
||||
* WMEnumerateHashTable() and WMNextHashEnumeratorItemAndKey() calls */
|
||||
|
||||
if (enumerator->nextItem==NULL) {
|
||||
HashTable *table = enumerator->table;
|
||||
while (++enumerator->index < table->size) {
|
||||
if (table->table[enumerator->index]!=NULL) {
|
||||
enumerator->nextItem = table->table[enumerator->index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
HashTable *table = enumerator->table;
|
||||
while (++enumerator->index < table->size) {
|
||||
if (table->table[enumerator->index]!=NULL) {
|
||||
enumerator->nextItem = table->table[enumerator->index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enumerator->nextItem) {
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
void
|
||||
InitI18n(Display *dpy)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
+41
-41
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Window Maker miscelaneous function library
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1997-2003 Alfredo K. Kojima
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
@@ -47,9 +47,9 @@ static void
|
||||
defaultHandler(int bla)
|
||||
{
|
||||
if (bla)
|
||||
kill(getpid(), SIGABRT);
|
||||
kill(getpid(), SIGABRT);
|
||||
else
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,23 +89,23 @@ wmalloc(size_t size)
|
||||
tmp = malloc(size);
|
||||
#endif
|
||||
if (tmp == NULL) {
|
||||
wwarning("malloc() failed. Retrying after 2s.");
|
||||
sleep(2);
|
||||
wwarning("malloc() failed. Retrying after 2s.");
|
||||
sleep(2);
|
||||
#ifdef TEST_WITH_GC
|
||||
tmp = GC_malloc(size);
|
||||
#else
|
||||
tmp = malloc(size);
|
||||
#endif
|
||||
if (tmp == NULL) {
|
||||
if (Aborting) {
|
||||
fputs("Really Bad Error: recursive malloc() failure.", stderr);
|
||||
exit(-1);
|
||||
} else {
|
||||
wfatal("virtual memory exhausted");
|
||||
Aborting=1;
|
||||
wAbort(False);
|
||||
}
|
||||
}
|
||||
if (tmp == NULL) {
|
||||
if (Aborting) {
|
||||
fputs("Really Bad Error: recursive malloc() failure.", stderr);
|
||||
exit(-1);
|
||||
} else {
|
||||
wfatal("virtual memory exhausted");
|
||||
Aborting=1;
|
||||
wAbort(False);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
@@ -117,15 +117,15 @@ wrealloc(void *ptr, size_t newsize)
|
||||
void *nptr;
|
||||
|
||||
if (!ptr) {
|
||||
nptr = wmalloc(newsize);
|
||||
nptr = wmalloc(newsize);
|
||||
} else if (newsize==0) {
|
||||
wfree(ptr);
|
||||
nptr = NULL;
|
||||
} else {
|
||||
#ifdef TEST_WITH_GC
|
||||
nptr = GC_realloc(ptr, newsize);
|
||||
nptr = GC_realloc(ptr, newsize);
|
||||
#else
|
||||
nptr = realloc(ptr, newsize);
|
||||
nptr = realloc(ptr, newsize);
|
||||
#endif
|
||||
if (nptr==NULL) {
|
||||
wwarning("realloc() failed. Retrying after 2s.");
|
||||
@@ -156,26 +156,26 @@ void*
|
||||
wretain(void *ptr)
|
||||
{
|
||||
int *refcount;
|
||||
|
||||
|
||||
if (!table) {
|
||||
table = WMCreateHashTable(WMIntHashCallbacks);
|
||||
table = WMCreateHashTable(WMIntHashCallbacks);
|
||||
}
|
||||
|
||||
|
||||
refcount = WMHashGet(table, ptr);
|
||||
if (!refcount) {
|
||||
refcount = wmalloc(sizeof(int));
|
||||
*refcount = 1;
|
||||
WMHashInsert(table, ptr, refcount);
|
||||
refcount = wmalloc(sizeof(int));
|
||||
*refcount = 1;
|
||||
WMHashInsert(table, ptr, refcount);
|
||||
#ifdef VERBOSE
|
||||
printf("== %i (%p)\n", *refcount, ptr);
|
||||
printf("== %i (%p)\n", *refcount, ptr);
|
||||
#endif
|
||||
} else {
|
||||
(*refcount)++;
|
||||
(*refcount)++;
|
||||
#ifdef VERBOSE
|
||||
printf("+ %i (%p)\n", *refcount, ptr);
|
||||
printf("+ %i (%p)\n", *refcount, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -197,24 +197,24 @@ void
|
||||
wrelease(void *ptr)
|
||||
{
|
||||
int *refcount;
|
||||
|
||||
|
||||
refcount = WMHashGet(table, ptr);
|
||||
if (!refcount) {
|
||||
wwarning("trying to release unexisting data %p", ptr);
|
||||
wwarning("trying to release unexisting data %p", ptr);
|
||||
} else {
|
||||
(*refcount)--;
|
||||
if (*refcount < 1) {
|
||||
(*refcount)--;
|
||||
if (*refcount < 1) {
|
||||
#ifdef VERBOSE
|
||||
printf("RELEASING %p\n", ptr);
|
||||
printf("RELEASING %p\n", ptr);
|
||||
#endif
|
||||
WMHashRemove(table, ptr);
|
||||
wfree(refcount);
|
||||
wfree(ptr);
|
||||
}
|
||||
WMHashRemove(table, ptr);
|
||||
wfree(refcount);
|
||||
wfree(ptr);
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
else {
|
||||
printf("- %i (%p)\n", *refcount, ptr);
|
||||
}
|
||||
else {
|
||||
printf("- %i (%p)\n", *refcount, ptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+190
-190
@@ -43,15 +43,15 @@ WMNotification*
|
||||
WMCreateNotification(const char *name, void *object, void *clientData)
|
||||
{
|
||||
Notification *nPtr;
|
||||
|
||||
|
||||
nPtr = wmalloc(sizeof(Notification));
|
||||
|
||||
|
||||
nPtr->name = name;
|
||||
nPtr->object = object;
|
||||
nPtr->clientData = clientData;
|
||||
|
||||
|
||||
nPtr->refCount = 1;
|
||||
|
||||
|
||||
return nPtr;
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ void
|
||||
WMReleaseNotification(WMNotification *notification)
|
||||
{
|
||||
notification->refCount--;
|
||||
|
||||
|
||||
if (notification->refCount < 1) {
|
||||
wfree(notification);
|
||||
wfree(notification);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ WMNotification*
|
||||
WMRetainNotification(WMNotification *notification)
|
||||
{
|
||||
notification->refCount++;
|
||||
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ typedef struct W_NotificationCenter {
|
||||
WMHashTable *nameTable; /* names -> observer lists */
|
||||
WMHashTable *objectTable; /* object -> observer lists */
|
||||
NotificationObserver *nilList; /* obervers that catch everything */
|
||||
|
||||
|
||||
WMHashTable *observerTable; /* observer -> NotificationObserver */
|
||||
} NotificationCenter;
|
||||
|
||||
@@ -108,21 +108,21 @@ void
|
||||
W_InitNotificationCenter(void)
|
||||
{
|
||||
notificationCenter = wmalloc(sizeof(NotificationCenter));
|
||||
|
||||
|
||||
notificationCenter->nameTable = WMCreateHashTable(WMStringPointerHashCallbacks);
|
||||
notificationCenter->objectTable = WMCreateHashTable(WMIntHashCallbacks);
|
||||
notificationCenter->nilList = NULL;
|
||||
|
||||
|
||||
notificationCenter->observerTable = WMCreateHashTable(WMIntHashCallbacks);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
void *observer, const char *name, void *object)
|
||||
void *observer, const char *name, void *object)
|
||||
{
|
||||
NotificationObserver *oRec, *rec;
|
||||
|
||||
|
||||
oRec = wmalloc(sizeof(NotificationObserver));
|
||||
oRec->observerAction = observerAction;
|
||||
oRec->observer = observer;
|
||||
@@ -130,42 +130,42 @@ WMAddNotificationObserver(WMNotificationObserverAction *observerAction,
|
||||
oRec->object = object;
|
||||
oRec->next = NULL;
|
||||
oRec->prev = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
/* put this action in the list of actions for this observer */
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->observerTable,
|
||||
observer, oRec);
|
||||
|
||||
observer, oRec);
|
||||
|
||||
if (rec) {
|
||||
/* if this is not the first action for the observer */
|
||||
oRec->nextAction = rec;
|
||||
/* if this is not the first action for the observer */
|
||||
oRec->nextAction = rec;
|
||||
} else {
|
||||
oRec->nextAction = NULL;
|
||||
oRec->nextAction = NULL;
|
||||
}
|
||||
|
||||
if (!name && !object) {
|
||||
/* catch-all */
|
||||
oRec->next = notificationCenter->nilList;
|
||||
if (notificationCenter->nilList) {
|
||||
notificationCenter->nilList->prev = oRec;
|
||||
}
|
||||
notificationCenter->nilList = oRec;
|
||||
/* catch-all */
|
||||
oRec->next = notificationCenter->nilList;
|
||||
if (notificationCenter->nilList) {
|
||||
notificationCenter->nilList->prev = oRec;
|
||||
}
|
||||
notificationCenter->nilList = oRec;
|
||||
} else if (!name) {
|
||||
/* any message coming from object */
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable,
|
||||
object, oRec);
|
||||
oRec->next = rec;
|
||||
if (rec) {
|
||||
rec->prev = oRec;
|
||||
}
|
||||
/* any message coming from object */
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->objectTable,
|
||||
object, oRec);
|
||||
oRec->next = rec;
|
||||
if (rec) {
|
||||
rec->prev = oRec;
|
||||
}
|
||||
} else {
|
||||
/* name && (object || !object) */
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable,
|
||||
name, oRec);
|
||||
oRec->next = rec;
|
||||
if (rec) {
|
||||
rec->prev = oRec;
|
||||
}
|
||||
/* name && (object || !object) */
|
||||
rec = (NotificationObserver*)WMHashInsert(notificationCenter->nameTable,
|
||||
name, oRec);
|
||||
oRec->next = rec;
|
||||
if (rec) {
|
||||
rec->prev = oRec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,49 +176,49 @@ WMPostNotification(WMNotification *notification)
|
||||
NotificationObserver *orec, *tmp;
|
||||
|
||||
WMRetainNotification(notification);
|
||||
|
||||
/* tell the observers that want to know about a particular message */
|
||||
orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
notification->name);
|
||||
|
||||
while (orec) {
|
||||
tmp = orec->next;
|
||||
|
||||
if (!orec->object || !notification->object
|
||||
|| orec->object == notification->object) {
|
||||
/* tell the observer */
|
||||
if (orec->observerAction) {
|
||||
(*orec->observerAction)(orec->observer, notification);
|
||||
}
|
||||
}
|
||||
|
||||
orec = tmp;
|
||||
/* tell the observers that want to know about a particular message */
|
||||
orec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
notification->name);
|
||||
|
||||
while (orec) {
|
||||
tmp = orec->next;
|
||||
|
||||
if (!orec->object || !notification->object
|
||||
|| orec->object == notification->object) {
|
||||
/* tell the observer */
|
||||
if (orec->observerAction) {
|
||||
(*orec->observerAction)(orec->observer, notification);
|
||||
}
|
||||
}
|
||||
|
||||
orec = tmp;
|
||||
}
|
||||
|
||||
/* tell the observers that want to know about an object */
|
||||
orec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
|
||||
notification->object);
|
||||
|
||||
notification->object);
|
||||
|
||||
while (orec) {
|
||||
tmp = orec->next;
|
||||
|
||||
/* tell the observer */
|
||||
if (orec->observerAction) {
|
||||
(*orec->observerAction)(orec->observer, notification);
|
||||
}
|
||||
orec = tmp;
|
||||
tmp = orec->next;
|
||||
|
||||
/* tell the observer */
|
||||
if (orec->observerAction) {
|
||||
(*orec->observerAction)(orec->observer, notification);
|
||||
}
|
||||
orec = tmp;
|
||||
}
|
||||
|
||||
/* tell the catch all observers */
|
||||
orec = notificationCenter->nilList;
|
||||
while (orec) {
|
||||
tmp = orec->next;
|
||||
tmp = orec->next;
|
||||
|
||||
/* tell the observer */
|
||||
if (orec->observerAction) {
|
||||
(*orec->observerAction)(orec->observer, notification);
|
||||
}
|
||||
orec = tmp;
|
||||
/* tell the observer */
|
||||
if (orec->observerAction) {
|
||||
(*orec->observerAction)(orec->observer, notification);
|
||||
}
|
||||
orec = tmp;
|
||||
}
|
||||
|
||||
WMReleaseNotification(notification);
|
||||
@@ -232,7 +232,7 @@ WMRemoveNotificationObserver(void *observer)
|
||||
|
||||
/* get the list of actions the observer is doing */
|
||||
orec = (NotificationObserver*)WMHashGet(notificationCenter->observerTable,
|
||||
observer);
|
||||
observer);
|
||||
|
||||
/*
|
||||
* FOREACH orec IN actionlist for observer
|
||||
@@ -242,47 +242,47 @@ WMRemoveNotificationObserver(void *observer)
|
||||
* END
|
||||
*/
|
||||
while (orec) {
|
||||
tmp = orec->nextAction;
|
||||
tmp = orec->nextAction;
|
||||
|
||||
if (!orec->name && !orec->object) {
|
||||
/* catch-all */
|
||||
if (notificationCenter->nilList==orec)
|
||||
notificationCenter->nilList = orec->next;
|
||||
} else if (!orec->name) {
|
||||
/* any message coming from object */
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
|
||||
orec->object);
|
||||
if (rec==orec) {
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->objectTable, orec->object,
|
||||
orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->objectTable, orec->object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* name && (object || !object) */
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
if (rec==orec) {
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->nameTable, orec->name,
|
||||
orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->nameTable, orec->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orec->prev)
|
||||
orec->prev->next = orec->next;
|
||||
if (orec->next)
|
||||
orec->next->prev = orec->prev;
|
||||
if (!orec->name && !orec->object) {
|
||||
/* catch-all */
|
||||
if (notificationCenter->nilList==orec)
|
||||
notificationCenter->nilList = orec->next;
|
||||
} else if (!orec->name) {
|
||||
/* any message coming from object */
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable,
|
||||
orec->object);
|
||||
if (rec==orec) {
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->objectTable, orec->object,
|
||||
orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->objectTable, orec->object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* name && (object || !object) */
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
if (rec==orec) {
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->nameTable, orec->name,
|
||||
orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->nameTable, orec->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orec->prev)
|
||||
orec->prev->next = orec->next;
|
||||
if (orec->next)
|
||||
orec->next->prev = orec->prev;
|
||||
|
||||
wfree(orec);
|
||||
|
||||
orec = tmp;
|
||||
wfree(orec);
|
||||
|
||||
orec = tmp;
|
||||
}
|
||||
|
||||
WMHashRemove(notificationCenter->observerTable, observer);
|
||||
@@ -303,66 +303,66 @@ WMRemoveNotificationObserverWithName(void *observer, const char *name, void *obj
|
||||
/* rebuild the list of actions for the observer */
|
||||
|
||||
while (orec) {
|
||||
tmp = orec->nextAction;
|
||||
if (orec->name == name && orec->object == object) {
|
||||
if (!name && !object) {
|
||||
if (notificationCenter->nilList == orec)
|
||||
notificationCenter->nilList = orec->next;
|
||||
} else if (!name) {
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object);
|
||||
if (rec==orec) {
|
||||
assert(rec->prev==NULL);
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->objectTable,
|
||||
orec->object, orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->objectTable,
|
||||
orec->object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
if (rec==orec) {
|
||||
assert(rec->prev==NULL);
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->nameTable,
|
||||
orec->name, orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp = orec->nextAction;
|
||||
if (orec->name == name && orec->object == object) {
|
||||
if (!name && !object) {
|
||||
if (notificationCenter->nilList == orec)
|
||||
notificationCenter->nilList = orec->next;
|
||||
} else if (!name) {
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->objectTable, orec->object);
|
||||
if (rec==orec) {
|
||||
assert(rec->prev==NULL);
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->objectTable,
|
||||
orec->object, orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->objectTable,
|
||||
orec->object);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rec = (NotificationObserver*)WMHashGet(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
if (rec==orec) {
|
||||
assert(rec->prev==NULL);
|
||||
/* replace table entry */
|
||||
if (orec->next) {
|
||||
WMHashInsert(notificationCenter->nameTable,
|
||||
orec->name, orec->next);
|
||||
} else {
|
||||
WMHashRemove(notificationCenter->nameTable,
|
||||
orec->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (orec->prev)
|
||||
orec->prev->next = orec->next;
|
||||
if (orec->next)
|
||||
orec->next->prev = orec->prev;
|
||||
wfree(orec);
|
||||
if (orec->prev)
|
||||
orec->prev->next = orec->next;
|
||||
if (orec->next)
|
||||
orec->next->prev = orec->prev;
|
||||
wfree(orec);
|
||||
} else {
|
||||
/* append this action in the new action list */
|
||||
orec->nextAction = NULL;
|
||||
if (!newList) {
|
||||
newList = orec;
|
||||
} else {
|
||||
NotificationObserver *p;
|
||||
/* append this action in the new action list */
|
||||
orec->nextAction = NULL;
|
||||
if (!newList) {
|
||||
newList = orec;
|
||||
} else {
|
||||
NotificationObserver *p;
|
||||
|
||||
p = newList;
|
||||
while (p->nextAction) {
|
||||
p = p->nextAction;
|
||||
}
|
||||
p->nextAction = orec;
|
||||
}
|
||||
}
|
||||
orec = tmp;
|
||||
p = newList;
|
||||
while (p->nextAction) {
|
||||
p = p->nextAction;
|
||||
}
|
||||
p->nextAction = orec;
|
||||
}
|
||||
}
|
||||
orec = tmp;
|
||||
}
|
||||
|
||||
/* reinsert the list to the table */
|
||||
if (newList) {
|
||||
WMHashInsert(notificationCenter->observerTable, observer, newList);
|
||||
WMHashInsert(notificationCenter->observerTable, observer, newList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ WMPostNotificationName(const char *name, void *object, void *clientData)
|
||||
WMNotification *notification;
|
||||
|
||||
notification = WMCreateNotification(name, object, clientData);
|
||||
|
||||
|
||||
WMPostNotification(notification);
|
||||
|
||||
WMReleaseNotification(notification);
|
||||
@@ -402,7 +402,7 @@ WMNotificationQueue*
|
||||
WMGetDefaultNotificationQueue(void)
|
||||
{
|
||||
if (!notificationQueue)
|
||||
notificationQueue = WMCreateNotificationQueue();
|
||||
notificationQueue = WMCreateNotificationQueue();
|
||||
|
||||
return notificationQueue;
|
||||
}
|
||||
@@ -430,10 +430,10 @@ WMCreateNotificationQueue(void)
|
||||
|
||||
void
|
||||
WMEnqueueNotification(WMNotificationQueue *queue, WMNotification *notification,
|
||||
WMPostingStyle postingStyle)
|
||||
WMPostingStyle postingStyle)
|
||||
{
|
||||
WMEnqueueCoalesceNotification(queue, notification, postingStyle,
|
||||
WNCOnName|WNCOnSender);
|
||||
WNCOnName|WNCOnSender);
|
||||
}
|
||||
|
||||
|
||||
@@ -465,8 +465,8 @@ matchName(void *item, void *cdata)
|
||||
|
||||
|
||||
void
|
||||
WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
||||
WMNotification *notification, unsigned mask)
|
||||
WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
||||
WMNotification *notification, unsigned mask)
|
||||
{
|
||||
WMMatchDataProc *matchFunc;
|
||||
|
||||
@@ -485,27 +485,27 @@ WMDequeueNotificationMatching(WMNotificationQueue *queue,
|
||||
|
||||
|
||||
void
|
||||
WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
WMPostingStyle postingStyle,
|
||||
unsigned coalesceMask)
|
||||
WMEnqueueCoalesceNotification(WMNotificationQueue *queue,
|
||||
WMNotification *notification,
|
||||
WMPostingStyle postingStyle,
|
||||
unsigned coalesceMask)
|
||||
{
|
||||
if (coalesceMask != WNCNone)
|
||||
WMDequeueNotificationMatching(queue, notification, coalesceMask);
|
||||
WMDequeueNotificationMatching(queue, notification, coalesceMask);
|
||||
|
||||
switch (postingStyle) {
|
||||
case WMPostNow:
|
||||
WMPostNotification(notification);
|
||||
case WMPostNow:
|
||||
WMPostNotification(notification);
|
||||
WMReleaseNotification(notification);
|
||||
break;
|
||||
|
||||
case WMPostASAP:
|
||||
WMAddToArray(queue->asapQueue, notification);
|
||||
break;
|
||||
case WMPostASAP:
|
||||
WMAddToArray(queue->asapQueue, notification);
|
||||
break;
|
||||
|
||||
case WMPostWhenIdle:
|
||||
WMAddToArray(queue->idleQueue, notification);
|
||||
break;
|
||||
case WMPostWhenIdle:
|
||||
WMAddToArray(queue->idleQueue, notification);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,12 +516,12 @@ W_FlushASAPNotificationQueue()
|
||||
WMNotificationQueue *queue = notificationQueueList;
|
||||
|
||||
while (queue) {
|
||||
while (WMGetArrayItemCount(queue->asapQueue)) {
|
||||
while (WMGetArrayItemCount(queue->asapQueue)) {
|
||||
WMPostNotification(WMGetFromArray(queue->asapQueue, 0));
|
||||
WMDeleteFromArray(queue->asapQueue, 0);
|
||||
}
|
||||
}
|
||||
|
||||
queue = queue->next;
|
||||
queue = queue->next;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,12 +532,12 @@ W_FlushIdleNotificationQueue()
|
||||
WMNotificationQueue *queue = notificationQueueList;
|
||||
|
||||
while (queue) {
|
||||
while (WMGetArrayItemCount(queue->idleQueue)) {
|
||||
WMPostNotification(WMGetFromArray(queue->idleQueue, 0));
|
||||
WMDeleteFromArray(queue->idleQueue, 0);
|
||||
}
|
||||
while (WMGetArrayItemCount(queue->idleQueue)) {
|
||||
WMPostNotification(WMGetFromArray(queue->idleQueue, 0));
|
||||
WMDeleteFromArray(queue->idleQueue, 0);
|
||||
}
|
||||
|
||||
queue = queue->next;
|
||||
queue = queue->next;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -98,8 +98,8 @@ static Bool caseSensitive = True;
|
||||
|
||||
#define CHECK_BUFFER_SIZE(buf, ptr) \
|
||||
if ((ptr) >= (buf).size-1) {\
|
||||
(buf).size += BUFFERSIZE_INCREMENT;\
|
||||
(buf).str = wrealloc((buf).str, (buf).size);\
|
||||
(buf).size += BUFFERSIZE_INCREMENT;\
|
||||
(buf).str = wrealloc((buf).str, (buf).size);\
|
||||
}
|
||||
|
||||
|
||||
@@ -132,9 +132,9 @@ hashPropList(WMPropList *plist)
|
||||
ctr = (ctr + 1) % sizeof (char *);
|
||||
}
|
||||
/*while (*key) {
|
||||
ret ^= tolower(*key++) << ctr;
|
||||
ctr = (ctr + 1) % sizeof (char *);
|
||||
}*/
|
||||
ret ^= tolower(*key++) << ctr;
|
||||
ctr = (ctr + 1) % sizeof (char *);
|
||||
}*/
|
||||
break;
|
||||
|
||||
case WPLData:
|
||||
@@ -1269,7 +1269,7 @@ WMSubtractPLDictionaries(WMPropList *dest, WMPropList *source, Bool recursive)
|
||||
if (WMIsPropListEqualTo(value, dvalue)) {
|
||||
WMRemoveFromPLDictionary(dest, key);
|
||||
} else if (recursive && value->type==WPLDictionary &&
|
||||
dvalue->type==WPLDictionary) {
|
||||
dvalue->type==WPLDictionary) {
|
||||
WMSubtractPLDictionaries(dvalue, value, True);
|
||||
}
|
||||
}
|
||||
|
||||
+121
-121
@@ -20,8 +20,8 @@ typedef struct SelectionHandler {
|
||||
void *data;
|
||||
|
||||
struct {
|
||||
unsigned delete_pending:1;
|
||||
unsigned done_pending:1;
|
||||
unsigned delete_pending:1;
|
||||
unsigned done_pending:1;
|
||||
} flags;
|
||||
} SelectionHandler;
|
||||
|
||||
@@ -35,8 +35,8 @@ typedef struct SelectionCallback {
|
||||
void *data;
|
||||
|
||||
struct {
|
||||
unsigned delete_pending:1;
|
||||
unsigned done_pending:1;
|
||||
unsigned delete_pending:1;
|
||||
unsigned done_pending:1;
|
||||
} flags;
|
||||
} SelectionCallback;
|
||||
|
||||
@@ -65,18 +65,18 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
|
||||
/*//printf("deleting selection handler for %d", win);*/
|
||||
|
||||
WM_ITERATE_ARRAY(selHandlers, handler, iter) {
|
||||
if (handler->view == view
|
||||
&& (handler->selection == selection || selection == None)
|
||||
&& (handler->timestamp == timestamp || timestamp == CurrentTime)) {
|
||||
if (handler->view == view
|
||||
&& (handler->selection == selection || selection == None)
|
||||
&& (handler->timestamp == timestamp || timestamp == CurrentTime)) {
|
||||
|
||||
if (handler->flags.done_pending) {
|
||||
handler->flags.delete_pending = 1;
|
||||
if (handler->flags.done_pending) {
|
||||
handler->flags.delete_pending = 1;
|
||||
/*//puts(": postponed because still pending");*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*//printf(": found & removed");*/
|
||||
WMRemoveFromArray(selHandlers, handler);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ WMDeleteSelectionHandler(WMView *view, Atom selection, Time timestamp)
|
||||
|
||||
XGrabServer(dpy);
|
||||
if (XGetSelectionOwner(dpy, selection) == win) {
|
||||
XSetSelectionOwner(dpy, selection, None, timestamp);
|
||||
XSetSelectionOwner(dpy, selection, None, timestamp);
|
||||
}
|
||||
XUngrabServer(dpy);
|
||||
}
|
||||
@@ -99,18 +99,18 @@ WMDeleteSelectionCallback(WMView *view, Atom selection, Time timestamp)
|
||||
|
||||
if (!selCallbacks)
|
||||
return;
|
||||
|
||||
WM_ITERATE_ARRAY(selCallbacks, handler, iter) {
|
||||
if (handler->view == view
|
||||
&& (handler->selection == selection || selection == None)
|
||||
&& (handler->timestamp == timestamp || timestamp == CurrentTime)) {
|
||||
|
||||
if (handler->flags.done_pending) {
|
||||
handler->flags.delete_pending = 1;
|
||||
return;
|
||||
}
|
||||
WMRemoveFromArray(selCallbacks, handler);
|
||||
break;
|
||||
WM_ITERATE_ARRAY(selCallbacks, handler, iter) {
|
||||
if (handler->view == view
|
||||
&& (handler->selection == selection || selection == None)
|
||||
&& (handler->timestamp == timestamp || timestamp == CurrentTime)) {
|
||||
|
||||
if (handler->flags.done_pending) {
|
||||
handler->flags.delete_pending = 1;
|
||||
return;
|
||||
}
|
||||
WMRemoveFromArray(selCallbacks, handler);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,14 +127,14 @@ handleXError(Display *dpy, XErrorEvent *ev)
|
||||
|
||||
static Bool
|
||||
writeSelection(Display *dpy, Window requestor, Atom property, Atom type,
|
||||
WMData *data)
|
||||
WMData *data)
|
||||
{
|
||||
static void *oldHandler;
|
||||
int format, bpi;
|
||||
|
||||
format = WMGetDataFormat(data);
|
||||
if (format == 0)
|
||||
format = 8;
|
||||
format = 8;
|
||||
|
||||
bpi = format/8;
|
||||
|
||||
@@ -171,9 +171,9 @@ notifySelection(XEvent *event, Atom prop)
|
||||
ev.xselection.selection = event->xselectionrequest.selection;
|
||||
ev.xselection.property = prop;
|
||||
ev.xselection.time = event->xselectionrequest.time;
|
||||
|
||||
XSendEvent(event->xany.display, event->xselectionrequest.requestor,
|
||||
False, 0, &ev);
|
||||
|
||||
XSendEvent(event->xany.display, event->xselectionrequest.requestor,
|
||||
False, 0, &ev);
|
||||
XFlush(event->xany.display);
|
||||
}
|
||||
|
||||
@@ -188,54 +188,54 @@ handleRequestEvent(XEvent *event)
|
||||
|
||||
WM_ITERATE_ARRAY(selHandlers, handler, iter) {
|
||||
|
||||
switch (event->type) {
|
||||
case SelectionClear:
|
||||
if (W_VIEW_DRAWABLE(handler->view)
|
||||
!= event->xselectionclear.window) {
|
||||
break;
|
||||
}
|
||||
switch (event->type) {
|
||||
case SelectionClear:
|
||||
if (W_VIEW_DRAWABLE(handler->view)
|
||||
!= event->xselectionclear.window) {
|
||||
break;
|
||||
}
|
||||
|
||||
handler->flags.done_pending = 1;
|
||||
if (handler->procs.selectionLost)
|
||||
handler->procs.selectionLost(handler->view,
|
||||
handler->selection,
|
||||
handler->data);
|
||||
handler->flags.done_pending = 0;
|
||||
handler->flags.delete_pending = 1;
|
||||
break;
|
||||
handler->flags.done_pending = 1;
|
||||
if (handler->procs.selectionLost)
|
||||
handler->procs.selectionLost(handler->view,
|
||||
handler->selection,
|
||||
handler->data);
|
||||
handler->flags.done_pending = 0;
|
||||
handler->flags.delete_pending = 1;
|
||||
break;
|
||||
|
||||
case SelectionRequest:
|
||||
if (W_VIEW_DRAWABLE(handler->view)!=event->xselectionrequest.owner) {
|
||||
break;
|
||||
}
|
||||
case SelectionRequest:
|
||||
if (W_VIEW_DRAWABLE(handler->view)!=event->xselectionrequest.owner) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (handler->procs.convertSelection != NULL
|
||||
&& handler->selection == event->xselectionrequest.selection) {
|
||||
Atom atom;
|
||||
WMData *data;
|
||||
Atom prop;
|
||||
if (handler->procs.convertSelection != NULL
|
||||
&& handler->selection == event->xselectionrequest.selection) {
|
||||
Atom atom;
|
||||
WMData *data;
|
||||
Atom prop;
|
||||
|
||||
/* they're requesting for something old.. maybe another handler
|
||||
* can handle it */
|
||||
if (event->xselectionrequest.time < handler->timestamp
|
||||
&& event->xselectionrequest.time != CurrentTime) {
|
||||
break;
|
||||
}
|
||||
/* they're requesting for something old.. maybe another handler
|
||||
* can handle it */
|
||||
if (event->xselectionrequest.time < handler->timestamp
|
||||
&& event->xselectionrequest.time != CurrentTime) {
|
||||
break;
|
||||
}
|
||||
|
||||
handledRequest = False;
|
||||
|
||||
handler->flags.done_pending = 1;
|
||||
handler->flags.done_pending = 1;
|
||||
|
||||
data = handler->procs.convertSelection(handler->view,
|
||||
handler->selection,
|
||||
event->xselectionrequest.target,
|
||||
handler->data,
|
||||
&atom);
|
||||
data = handler->procs.convertSelection(handler->view,
|
||||
handler->selection,
|
||||
event->xselectionrequest.target,
|
||||
handler->data,
|
||||
&atom);
|
||||
|
||||
prop = event->xselectionrequest.property;
|
||||
/* obsolete clients that don't set the property field */
|
||||
if (prop == None)
|
||||
prop = event->xselectionrequest.target;
|
||||
prop = event->xselectionrequest.property;
|
||||
/* obsolete clients that don't set the property field */
|
||||
if (prop == None)
|
||||
prop = event->xselectionrequest.target;
|
||||
|
||||
if (data) {
|
||||
if (writeSelection(event->xselectionrequest.display,
|
||||
@@ -248,17 +248,17 @@ handleRequestEvent(XEvent *event)
|
||||
|
||||
notifySelection(event, (handledRequest==True ? prop : None));
|
||||
|
||||
if (handler->procs.selectionDone != NULL) {
|
||||
handler->procs.selectionDone(handler->view,
|
||||
handler->selection,
|
||||
event->xselectionrequest.target,
|
||||
handler->data);
|
||||
}
|
||||
if (handler->procs.selectionDone != NULL) {
|
||||
handler->procs.selectionDone(handler->view,
|
||||
handler->selection,
|
||||
event->xselectionrequest.target,
|
||||
handler->data);
|
||||
}
|
||||
|
||||
handler->flags.done_pending = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
handler->flags.done_pending = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* delete handlers */
|
||||
@@ -283,10 +283,10 @@ getSelectionData(Display *dpy, Window win, Atom where)
|
||||
unsigned long len, bytes;
|
||||
|
||||
|
||||
if (XGetWindowProperty(dpy, win, where, 0, MAX_PROPERTY_SIZE,
|
||||
False, AnyPropertyType, &rtype, &bits, &len,
|
||||
&bytes, &data)!=Success) {
|
||||
return NULL;
|
||||
if (XGetWindowProperty(dpy, win, where, 0, MAX_PROPERTY_SIZE,
|
||||
False, AnyPropertyType, &rtype, &bits, &len,
|
||||
&bytes, &data)!=Success) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bpi = bits/8;
|
||||
@@ -307,30 +307,30 @@ handleNotifyEvent(XEvent *event)
|
||||
WMData *data;
|
||||
|
||||
WM_ITERATE_ARRAY(selCallbacks, handler, iter) {
|
||||
|
||||
if (W_VIEW_DRAWABLE(handler->view) != event->xselection.requestor
|
||||
|| handler->selection != event->xselection.selection) {
|
||||
continue;
|
||||
}
|
||||
handler->flags.done_pending = 1;
|
||||
|
||||
if (event->xselection.property == None) {
|
||||
data = NULL;
|
||||
} else {
|
||||
data = getSelectionData(event->xselection.display,
|
||||
event->xselection.requestor,
|
||||
event->xselection.property);
|
||||
}
|
||||
|
||||
(*handler->callback)(handler->view, handler->selection,
|
||||
handler->target, handler->timestamp,
|
||||
handler->data, data);
|
||||
if (W_VIEW_DRAWABLE(handler->view) != event->xselection.requestor
|
||||
|| handler->selection != event->xselection.selection) {
|
||||
continue;
|
||||
}
|
||||
handler->flags.done_pending = 1;
|
||||
|
||||
if (data != NULL) {
|
||||
WMReleaseData(data);
|
||||
}
|
||||
handler->flags.done_pending = 0;
|
||||
handler->flags.delete_pending = 1;
|
||||
if (event->xselection.property == None) {
|
||||
data = NULL;
|
||||
} else {
|
||||
data = getSelectionData(event->xselection.display,
|
||||
event->xselection.requestor,
|
||||
event->xselection.property);
|
||||
}
|
||||
|
||||
(*handler->callback)(handler->view, handler->selection,
|
||||
handler->target, handler->timestamp,
|
||||
handler->data, data);
|
||||
|
||||
if (data != NULL) {
|
||||
WMReleaseData(data);
|
||||
}
|
||||
handler->flags.done_pending = 0;
|
||||
handler->flags.delete_pending = 1;
|
||||
}
|
||||
|
||||
/* delete callbacks */
|
||||
@@ -351,20 +351,20 @@ W_HandleSelectionEvent(XEvent *event)
|
||||
{
|
||||
/*//printf("%d received selection ", event->xany.window);*/
|
||||
/*//switch(event->type) {
|
||||
case SelectionNotify:
|
||||
puts("notify"); break;
|
||||
case SelectionRequest:
|
||||
puts("request"); break;
|
||||
case SelectionClear:
|
||||
puts("clear"); break;
|
||||
default:
|
||||
puts("unknown"); break;
|
||||
}*/
|
||||
case SelectionNotify:
|
||||
puts("notify"); break;
|
||||
case SelectionRequest:
|
||||
puts("request"); break;
|
||||
case SelectionClear:
|
||||
puts("clear"); break;
|
||||
default:
|
||||
puts("unknown"); break;
|
||||
}*/
|
||||
|
||||
if (event->type == SelectionNotify) {
|
||||
handleNotifyEvent(event);
|
||||
handleNotifyEvent(event);
|
||||
} else {
|
||||
handleRequestEvent(event);
|
||||
handleRequestEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ W_HandleSelectionEvent(XEvent *event)
|
||||
|
||||
Bool
|
||||
WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
|
||||
WMSelectionProcs *procs, void *cdata)
|
||||
WMSelectionProcs *procs, void *cdata)
|
||||
{
|
||||
SelectionHandler *handler;
|
||||
Display *dpy = W_VIEW_SCREEN(view)->display;
|
||||
@@ -397,7 +397,7 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
|
||||
memset(&handler->flags, 0, sizeof(handler->flags));
|
||||
|
||||
if (selHandlers == NULL) {
|
||||
selHandlers = WMCreateArrayWithDestructor(4, wfree);
|
||||
selHandlers = WMCreateArrayWithDestructor(4, wfree);
|
||||
}
|
||||
|
||||
WMAddToArray(selHandlers, handler);
|
||||
@@ -409,16 +409,16 @@ WMCreateSelectionHandler(WMView *view, Atom selection, Time timestamp,
|
||||
|
||||
Bool
|
||||
WMRequestSelection(WMView *view, Atom selection, Atom target, Time timestamp,
|
||||
WMSelectionCallback *callback, void *cdata)
|
||||
WMSelectionCallback *callback, void *cdata)
|
||||
{
|
||||
SelectionCallback *handler;
|
||||
|
||||
if (XGetSelectionOwner(W_VIEW_SCREEN(view)->display, selection) == None)
|
||||
return False;
|
||||
return False;
|
||||
|
||||
if (!XConvertSelection(W_VIEW_SCREEN(view)->display, selection, target,
|
||||
W_VIEW_SCREEN(view)->clipboardAtom,
|
||||
W_VIEW_DRAWABLE(view), timestamp)) {
|
||||
W_VIEW_SCREEN(view)->clipboardAtom,
|
||||
W_VIEW_DRAWABLE(view), timestamp)) {
|
||||
return False;
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ WMRequestSelection(WMView *view, Atom selection, Atom target, Time timestamp,
|
||||
memset(&handler->flags, 0, sizeof(handler->flags));
|
||||
|
||||
if (selCallbacks == NULL) {
|
||||
selCallbacks = WMCreateArrayWithDestructor(4, wfree);
|
||||
selCallbacks = WMCreateArrayWithDestructor(4, wfree);
|
||||
}
|
||||
|
||||
WMAddToArray(selCallbacks, handler);
|
||||
|
||||
@@ -935,3 +935,4 @@ int main (void)
|
||||
return 0;
|
||||
}
|
||||
#endif /* SNPRINTF_TEST */
|
||||
|
||||
+46
-46
@@ -43,46 +43,46 @@ wtokennext(char *word, char **next)
|
||||
|
||||
t = ret = wmalloc(strlen(word)+1);
|
||||
ptr = word;
|
||||
|
||||
|
||||
state = 0;
|
||||
*t = 0;
|
||||
while (1) {
|
||||
if (*ptr==0)
|
||||
ctype = PRC_EOS;
|
||||
else if (*ptr=='\\')
|
||||
ctype = PRC_ESCAPE;
|
||||
else if (*ptr=='"')
|
||||
ctype = PRC_DQUOTE;
|
||||
else if (*ptr=='\'')
|
||||
ctype = PRC_SQUOTE;
|
||||
else if (*ptr==' ' || *ptr=='\t')
|
||||
ctype = PRC_BLANK;
|
||||
else
|
||||
ctype = PRC_ALPHA;
|
||||
if (*ptr==0)
|
||||
ctype = PRC_EOS;
|
||||
else if (*ptr=='\\')
|
||||
ctype = PRC_ESCAPE;
|
||||
else if (*ptr=='"')
|
||||
ctype = PRC_DQUOTE;
|
||||
else if (*ptr=='\'')
|
||||
ctype = PRC_SQUOTE;
|
||||
else if (*ptr==' ' || *ptr=='\t')
|
||||
ctype = PRC_BLANK;
|
||||
else
|
||||
ctype = PRC_ALPHA;
|
||||
|
||||
if (mtable[state][ctype].output) {
|
||||
*t = *ptr; t++;
|
||||
*t = 0;
|
||||
}
|
||||
state = mtable[state][ctype].nstate;
|
||||
ptr++;
|
||||
if (mtable[state][0].output<0) {
|
||||
break;
|
||||
}
|
||||
if (mtable[state][ctype].output) {
|
||||
*t = *ptr; t++;
|
||||
*t = 0;
|
||||
}
|
||||
state = mtable[state][ctype].nstate;
|
||||
ptr++;
|
||||
if (mtable[state][0].output<0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (*ret==0)
|
||||
t = NULL;
|
||||
t = NULL;
|
||||
else
|
||||
t = wstrdup(ret);
|
||||
t = wstrdup(ret);
|
||||
|
||||
wfree(ret);
|
||||
|
||||
|
||||
if (ctype==PRC_EOS)
|
||||
*next = NULL;
|
||||
*next = NULL;
|
||||
else
|
||||
*next = ptr;
|
||||
|
||||
*next = ptr;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -97,14 +97,14 @@ wtokensplit(char *command, char ***argv, int *argc)
|
||||
count = 0;
|
||||
line = command;
|
||||
do {
|
||||
token = wtokennext(line, &line);
|
||||
if (token) {
|
||||
if (count == 0)
|
||||
*argv = wmalloc(sizeof(char**));
|
||||
else
|
||||
*argv = wrealloc(*argv, (count+1)*sizeof(char**));
|
||||
(*argv)[count++] = token;
|
||||
}
|
||||
token = wtokennext(line, &line);
|
||||
if (token) {
|
||||
if (count == 0)
|
||||
*argv = wmalloc(sizeof(char**));
|
||||
else
|
||||
*argv = wrealloc(*argv, (count+1)*sizeof(char**));
|
||||
(*argv)[count++] = token;
|
||||
}
|
||||
} while (token!=NULL && line!=NULL);
|
||||
|
||||
*argc = count;
|
||||
@@ -128,21 +128,21 @@ wtokenjoin(char **list, int count)
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
flat_string = wmalloc(j+count+1);
|
||||
|
||||
*flat_string = 0;
|
||||
for (i=0; i<count; i++) {
|
||||
if (list[i]!=NULL && list[i][0]!=0) {
|
||||
if (i>0)
|
||||
strcat(flat_string, " ");
|
||||
if (list[i]!=NULL && list[i][0]!=0) {
|
||||
if (i>0)
|
||||
strcat(flat_string, " ");
|
||||
wspace = strpbrk(list[i], " \t");
|
||||
if (wspace)
|
||||
strcat(flat_string, "\"");
|
||||
strcat(flat_string, list[i]);
|
||||
strcat(flat_string, list[i]);
|
||||
if (wspace)
|
||||
strcat(flat_string, "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flat_string;
|
||||
@@ -207,9 +207,9 @@ wstrconcat(char *str1, char *str2)
|
||||
char *str;
|
||||
|
||||
if (!str1)
|
||||
return wstrdup(str2);
|
||||
return wstrdup(str2);
|
||||
else if (!str2)
|
||||
return wstrdup(str1);
|
||||
return wstrdup(str1);
|
||||
|
||||
str = wmalloc(strlen(str1)+strlen(str2)+1);
|
||||
strcpy(str, str1);
|
||||
@@ -223,9 +223,9 @@ char*
|
||||
wstrappend(char *dst, char *src)
|
||||
{
|
||||
if (!dst)
|
||||
return wstrdup(src);
|
||||
return wstrdup(src);
|
||||
else if (!src || *src==0)
|
||||
return dst;
|
||||
return dst;
|
||||
|
||||
dst = wrealloc(dst, strlen(dst)+strlen(src)+1);
|
||||
strcat(dst, src);
|
||||
|
||||
+59
-59
@@ -57,19 +57,19 @@ wusergnusteppath()
|
||||
int pathlen;
|
||||
|
||||
if (!path) {
|
||||
gspath = getenv("GNUSTEP_USER_ROOT");
|
||||
if (gspath) {
|
||||
gspath = wexpandpath(gspath);
|
||||
pathlen = strlen(gspath) + 4;
|
||||
path = wmalloc(pathlen);
|
||||
strcpy(path, gspath);
|
||||
wfree(gspath);
|
||||
} else {
|
||||
pathlen = strlen(wgethomedir()) + 10;
|
||||
path = wmalloc(pathlen);
|
||||
strcpy(path, wgethomedir());
|
||||
strcat(path, "/GNUstep");
|
||||
}
|
||||
gspath = getenv("GNUSTEP_USER_ROOT");
|
||||
if (gspath) {
|
||||
gspath = wexpandpath(gspath);
|
||||
pathlen = strlen(gspath) + 4;
|
||||
path = wmalloc(pathlen);
|
||||
strcpy(path, gspath);
|
||||
wfree(gspath);
|
||||
} else {
|
||||
pathlen = strlen(wgethomedir()) + 10;
|
||||
path = wmalloc(pathlen);
|
||||
strcpy(path, wgethomedir());
|
||||
strcat(path, "/GNUstep");
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
@@ -436,24 +436,24 @@ WMGetUDObjectForKey(WMUserDefaults *database, char *defaultName)
|
||||
WMPropList *object = NULL;
|
||||
WMPropList *key = WMCreatePLString(defaultName);
|
||||
int i = 0;
|
||||
|
||||
|
||||
while (database->searchList[i] && !object) {
|
||||
domainName = database->searchList[i];
|
||||
domain = WMGetFromPLDictionary(database->defaults, domainName);
|
||||
if (domain) {
|
||||
object = WMGetFromPLDictionary(domain, key);
|
||||
}
|
||||
i++;
|
||||
domainName = database->searchList[i];
|
||||
domain = WMGetFromPLDictionary(database->defaults, domainName);
|
||||
if (domain) {
|
||||
object = WMGetFromPLDictionary(domain, key);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
WMReleasePropList(key);
|
||||
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetUDObjectForKey(WMUserDefaults *database, WMPropList *object,
|
||||
char *defaultName)
|
||||
char *defaultName)
|
||||
{
|
||||
WMPropList *key = WMCreatePLString(defaultName);
|
||||
|
||||
@@ -472,7 +472,7 @@ WMRemoveUDObjectForKey(WMUserDefaults *database, char *defaultName)
|
||||
database->dirty = 1;
|
||||
|
||||
WMRemoveFromPLDictionary(database->appDomain, key);
|
||||
|
||||
|
||||
WMReleasePropList(key);
|
||||
}
|
||||
|
||||
@@ -481,14 +481,14 @@ char*
|
||||
WMGetUDStringForKey(WMUserDefaults *database, char *defaultName)
|
||||
{
|
||||
WMPropList *val;
|
||||
|
||||
|
||||
val = WMGetUDObjectForKey(database, defaultName);
|
||||
|
||||
if (!val)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (!WMIsPLString(val))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
return WMGetFromPLString(val);
|
||||
}
|
||||
@@ -502,19 +502,19 @@ WMGetUDIntegerForKey(WMUserDefaults *database, char *defaultName)
|
||||
int value;
|
||||
|
||||
val = WMGetUDObjectForKey(database, defaultName);
|
||||
|
||||
|
||||
if (!val)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
if (!WMIsPLString(val))
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
str = WMGetFromPLString(val);
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
if (sscanf(str, "%i", &value)!=1)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -529,15 +529,15 @@ WMGetUDFloatForKey(WMUserDefaults *database, char *defaultName)
|
||||
float value;
|
||||
|
||||
val = WMGetUDObjectForKey(database, defaultName);
|
||||
|
||||
|
||||
if (!val || !WMIsPLString(val))
|
||||
return 0.0;
|
||||
return 0.0;
|
||||
|
||||
if (!(str = WMGetFromPLString(val)))
|
||||
return 0.0;
|
||||
return 0.0;
|
||||
|
||||
if (sscanf(str, "%f", &value)!=1)
|
||||
return 0.0;
|
||||
return 0.0;
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -552,25 +552,25 @@ WMGetUDBoolForKey(WMUserDefaults *database, char *defaultName)
|
||||
char *str;
|
||||
|
||||
val = WMGetUDObjectForKey(database, defaultName);
|
||||
|
||||
|
||||
if (!val)
|
||||
return False;
|
||||
return False;
|
||||
|
||||
if (!WMIsPLString(val))
|
||||
return False;
|
||||
|
||||
return False;
|
||||
|
||||
str = WMGetFromPLString(val);
|
||||
if (!str)
|
||||
return False;
|
||||
|
||||
return False;
|
||||
|
||||
if (sscanf(str, "%i", &value)==1 && value!=0)
|
||||
return True;
|
||||
return True;
|
||||
|
||||
if (strcasecmp(str, "YES")==0)
|
||||
return True;
|
||||
return True;
|
||||
|
||||
if (strcasecmp(str, "Y")==0)
|
||||
return True;
|
||||
return True;
|
||||
|
||||
return False;
|
||||
}
|
||||
@@ -584,7 +584,7 @@ WMSetUDIntegerForKey(WMUserDefaults *database, int value, char *defaultName)
|
||||
|
||||
sprintf(buffer, "%i", value);
|
||||
object = WMCreatePLString(buffer);
|
||||
|
||||
|
||||
WMSetUDObjectForKey(database, object, defaultName);
|
||||
WMReleasePropList(object);
|
||||
}
|
||||
@@ -626,8 +626,8 @@ WMSetUDBoolForKey(WMUserDefaults *database, Bool value, char *defaultName)
|
||||
static WMPropList *yes = NULL, *no = NULL;
|
||||
|
||||
if (!yes) {
|
||||
yes = WMCreatePLString("YES");
|
||||
no = WMCreatePLString("NO");
|
||||
yes = WMCreatePLString("YES");
|
||||
no = WMCreatePLString("NO");
|
||||
}
|
||||
|
||||
WMSetUDObjectForKey(database, value ? yes : no, defaultName);
|
||||
@@ -645,27 +645,27 @@ void
|
||||
WMSetUDSearchList(WMUserDefaults *database, WMPropList *list)
|
||||
{
|
||||
int i, c;
|
||||
|
||||
|
||||
if (database->searchList) {
|
||||
i = 0;
|
||||
while (database->searchList[i]) {
|
||||
WMReleasePropList(database->searchList[i]);
|
||||
i++;
|
||||
}
|
||||
wfree(database->searchList);
|
||||
i = 0;
|
||||
while (database->searchList[i]) {
|
||||
WMReleasePropList(database->searchList[i]);
|
||||
i++;
|
||||
}
|
||||
wfree(database->searchList);
|
||||
}
|
||||
if (database->searchListArray) {
|
||||
WMReleasePropList(database->searchListArray);
|
||||
WMReleasePropList(database->searchListArray);
|
||||
}
|
||||
|
||||
c = WMGetPropListItemCount(list);
|
||||
database->searchList = wmalloc(sizeof(WMPropList*)*(c+1));
|
||||
|
||||
for (i=0; i<c; i++) {
|
||||
database->searchList[i] = WMGetFromPLArray(list, i);
|
||||
database->searchList[i] = WMGetFromPLArray(list, i);
|
||||
}
|
||||
database->searchList[c] = NULL;
|
||||
|
||||
|
||||
database->searchListArray = WMDeepCopyPropList(list);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -36,9 +36,9 @@ wusleep(unsigned int microsecs)
|
||||
|
||||
#else /* not HAVE_SELECT */
|
||||
|
||||
# ifdef HAVE_POLL
|
||||
# ifdef HAVE_POLL
|
||||
|
||||
void
|
||||
void
|
||||
wusleep(unsigned int microsecs)
|
||||
{
|
||||
poll((struct poll *) 0, (size_t) 0, microsecs/1000);
|
||||
|
||||
+72
-72
@@ -19,7 +19,7 @@ char *_WINGS_progname = NULL;
|
||||
|
||||
|
||||
|
||||
Bool
|
||||
Bool
|
||||
W_ApplicationInitialized(void)
|
||||
{
|
||||
return _WINGS_progname!=NULL;
|
||||
@@ -40,9 +40,9 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv)
|
||||
|
||||
#ifdef I18N
|
||||
if (getenv("NLSPATH"))
|
||||
bindtextdomain("WINGs", getenv("NLSPATH"));
|
||||
bindtextdomain("WINGs", getenv("NLSPATH"));
|
||||
else
|
||||
bindtextdomain("WINGs", LOCALEDIR);
|
||||
bindtextdomain("WINGs", LOCALEDIR);
|
||||
#endif
|
||||
|
||||
_WINGS_progname = argv[0];
|
||||
@@ -52,7 +52,7 @@ WMInitializeApplication(char *applicationName, int *argc, char **argv)
|
||||
|
||||
WMApplication.argv = wmalloc((*argc+1)*sizeof(char*));
|
||||
for (i=0; i<*argc; i++) {
|
||||
WMApplication.argv[i] = wstrdup(argv[i]);
|
||||
WMApplication.argv[i] = wstrdup(argv[i]);
|
||||
}
|
||||
WMApplication.argv[i] = NULL;
|
||||
|
||||
@@ -65,7 +65,7 @@ void
|
||||
WMSetResourcePath(char *path)
|
||||
{
|
||||
if (WMApplication.resourcePath)
|
||||
wfree(WMApplication.resourcePath);
|
||||
wfree(WMApplication.resourcePath);
|
||||
WMApplication.resourcePath = wstrdup(path);
|
||||
}
|
||||
|
||||
@@ -82,24 +82,24 @@ checkFile(char *path, char *folder, char *ext, char *resource)
|
||||
{
|
||||
char *ret;
|
||||
int extralen;
|
||||
|
||||
extralen = (ext ? strlen(ext) : 0) + (folder ? strlen(folder) : 0) + 4;
|
||||
|
||||
extralen = (ext ? strlen(ext) : 0) + (folder ? strlen(folder) : 0) + 4;
|
||||
ret = wmalloc(strlen(path)+strlen(resource)+extralen+8);
|
||||
strcpy(ret, path);
|
||||
if (folder) {
|
||||
strcat(ret, "/");
|
||||
strcat(ret, folder);
|
||||
strcat(ret, "/");
|
||||
strcat(ret, folder);
|
||||
}
|
||||
if (ext) {
|
||||
strcat(ret, "/");
|
||||
strcat(ret, ext);
|
||||
strcat(ret, "/");
|
||||
strcat(ret, ext);
|
||||
}
|
||||
strcat(ret, "/");
|
||||
strcat(ret, resource);
|
||||
|
||||
|
||||
if (access(ret, F_OK)!=0) {
|
||||
wfree(ret);
|
||||
ret = NULL;
|
||||
wfree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -112,90 +112,90 @@ WMPathForResourceOfType(char *resource, char *ext)
|
||||
char *path = NULL;
|
||||
char *tmp, *appdir;
|
||||
int i;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Paths are searched in this order:
|
||||
* - resourcePath/ext
|
||||
* - argv[0]/ext
|
||||
* - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext
|
||||
* - GNUSTEP_USER_ROOT/Apps/ApplicationName.app/ext
|
||||
* - ~/GNUstep/Apps/ApplicationName.app/ext
|
||||
* - GNUSTEP_LOCAL_ROOT/Apps/ApplicationName.app/ext
|
||||
* - /usr/local/GNUstep/Apps/ApplicationName.app/ext
|
||||
* - GNUSTEP_SYSTEM_ROOT/Apps/ApplicationName.app/ext
|
||||
* - /usr/GNUstep/Apps/ApplicationName.app/ext
|
||||
*/
|
||||
|
||||
|
||||
if (WMApplication.resourcePath) {
|
||||
path = checkFile(WMApplication.resourcePath, NULL, ext, resource);
|
||||
if (path)
|
||||
return path;
|
||||
path = checkFile(WMApplication.resourcePath, NULL, ext, resource);
|
||||
if (path)
|
||||
return path;
|
||||
}
|
||||
|
||||
if (WMApplication.argv[0]) {
|
||||
tmp = wstrdup(WMApplication.argv[0]);
|
||||
i = strlen(tmp);
|
||||
while (i > 0 && tmp[i]!='/')
|
||||
i--;
|
||||
tmp[i] = 0;
|
||||
if (i>0) {
|
||||
path = checkFile(tmp, NULL, ext, resource);
|
||||
} else {
|
||||
path = NULL;
|
||||
}
|
||||
wfree(tmp);
|
||||
if (path)
|
||||
return path;
|
||||
tmp = wstrdup(WMApplication.argv[0]);
|
||||
i = strlen(tmp);
|
||||
while (i > 0 && tmp[i]!='/')
|
||||
i--;
|
||||
tmp[i] = 0;
|
||||
if (i>0) {
|
||||
path = checkFile(tmp, NULL, ext, resource);
|
||||
} else {
|
||||
path = NULL;
|
||||
}
|
||||
wfree(tmp);
|
||||
if (path)
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
appdir = wmalloc(strlen(WMApplication.applicationName)+10);
|
||||
sprintf(appdir, "Apps/%s.app", WMApplication.applicationName);
|
||||
|
||||
if (getenv("GNUSTEP_USER_ROOT")) {
|
||||
path = checkFile(getenv("GNUSTEP_USER_ROOT"), appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = wusergnusteppath();
|
||||
if (tmp) {
|
||||
path = checkFile(tmp, appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
if (getenv("GNUSTEP_LOCAL_ROOT")) {
|
||||
path = checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
path = checkFile("/usr/local/GNUstep", appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
path = checkFile(getenv("GNUSTEP_USER_ROOT"), appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tmp = wusergnusteppath();
|
||||
if (tmp) {
|
||||
path = checkFile(tmp, appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
if (getenv("GNUSTEP_LOCAL_ROOT")) {
|
||||
path = checkFile(getenv("GNUSTEP_LOCAL_ROOT"), appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
path = checkFile("/usr/local/GNUstep", appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
if (getenv("GNUSTEP_SYSTEM_ROOT")) {
|
||||
path = checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
path = checkFile(getenv("GNUSTEP_SYSTEM_ROOT"), appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
path = checkFile("/usr/GNUstep", appdir, ext, resource);
|
||||
if (path) {
|
||||
wfree(appdir);
|
||||
return path;
|
||||
wfree(appdir);
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
+34
-34
@@ -19,14 +19,14 @@ WMSetApplicationIconWindow(WMScreen *scr, Window window)
|
||||
scr->applicationIconWindow = window;
|
||||
|
||||
if (scr->groupLeader) {
|
||||
XWMHints *hints;
|
||||
XWMHints *hints;
|
||||
|
||||
hints = XGetWMHints(scr->display, scr->groupLeader);
|
||||
hints->flags |= IconWindowHint;
|
||||
hints->icon_window = window;
|
||||
hints = XGetWMHints(scr->display, scr->groupLeader);
|
||||
hints->flags |= IconWindowHint;
|
||||
hints->icon_window = window;
|
||||
|
||||
XSetWMHints(scr->display, scr->groupLeader, hints);
|
||||
XFree(hints);
|
||||
XSetWMHints(scr->display, scr->groupLeader, hints);
|
||||
XFree(hints);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ WMSetApplicationIconImage(WMScreen *scr, RImage *image)
|
||||
return;
|
||||
|
||||
if (scr->applicationIconImage)
|
||||
RReleaseImage(scr->applicationIconImage);
|
||||
RReleaseImage(scr->applicationIconImage);
|
||||
|
||||
scr->applicationIconImage = RRetainImage(image);
|
||||
|
||||
@@ -66,20 +66,20 @@ WMSetApplicationIconPixmap(WMScreen *scr, WMPixmap *icon)
|
||||
return;
|
||||
|
||||
if (scr->applicationIconPixmap)
|
||||
WMReleasePixmap(scr->applicationIconPixmap);
|
||||
WMReleasePixmap(scr->applicationIconPixmap);
|
||||
|
||||
scr->applicationIconPixmap = WMRetainPixmap(icon);
|
||||
|
||||
if (scr->groupLeader) {
|
||||
XWMHints *hints;
|
||||
XWMHints *hints;
|
||||
|
||||
hints = XGetWMHints(scr->display, scr->groupLeader);
|
||||
hints->flags |= IconPixmapHint|IconMaskHint;
|
||||
hints = XGetWMHints(scr->display, scr->groupLeader);
|
||||
hints->flags |= IconPixmapHint|IconMaskHint;
|
||||
hints->icon_pixmap = (icon!=NULL ? icon->pixmap : None);
|
||||
hints->icon_mask = (icon!=NULL ? icon->mask : None);
|
||||
|
||||
XSetWMHints(scr->display, scr->groupLeader, hints);
|
||||
XFree(hints);
|
||||
XSetWMHints(scr->display, scr->groupLeader, hints);
|
||||
XFree(hints);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,40 +132,40 @@ W_InitApplication(WMScreen *scr)
|
||||
XWMHints *hints;
|
||||
|
||||
leader = XCreateSimpleWindow(scr->display, scr->rootWin, -1, -1,
|
||||
1, 1, 0, 0, 0);
|
||||
1, 1, 0, 0, 0);
|
||||
|
||||
if (!scr->aflags.simpleApplication) {
|
||||
classHint = XAllocClassHint();
|
||||
classHint->res_name = "groupLeader";
|
||||
classHint->res_class = WMApplication.applicationName;
|
||||
XSetClassHint(scr->display, leader, classHint);
|
||||
XFree(classHint);
|
||||
classHint = XAllocClassHint();
|
||||
classHint->res_name = "groupLeader";
|
||||
classHint->res_class = WMApplication.applicationName;
|
||||
XSetClassHint(scr->display, leader, classHint);
|
||||
XFree(classHint);
|
||||
|
||||
XSetCommand(scr->display, leader, WMApplication.argv,
|
||||
WMApplication.argc);
|
||||
XSetCommand(scr->display, leader, WMApplication.argv,
|
||||
WMApplication.argc);
|
||||
|
||||
hints = XAllocWMHints();
|
||||
hints = XAllocWMHints();
|
||||
|
||||
hints->flags = WindowGroupHint;
|
||||
hints->window_group = leader;
|
||||
hints->flags = WindowGroupHint;
|
||||
hints->window_group = leader;
|
||||
|
||||
/* This code will never actually be reached, because to have
|
||||
* scr->applicationIconPixmap set we need to have a screen first,
|
||||
* but this function is called in the screen creation process.
|
||||
* -Dan
|
||||
*/
|
||||
if (scr->applicationIconPixmap) {
|
||||
if (scr->applicationIconPixmap) {
|
||||
hints->flags |= IconPixmapHint;
|
||||
hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
|
||||
if (scr->applicationIconPixmap->mask) {
|
||||
hints->flags |= IconMaskHint;
|
||||
hints->icon_mask = scr->applicationIconPixmap->mask;
|
||||
}
|
||||
}
|
||||
|
||||
XSetWMHints(scr->display, leader, hints);
|
||||
hints->icon_pixmap = scr->applicationIconPixmap->pixmap;
|
||||
if (scr->applicationIconPixmap->mask) {
|
||||
hints->flags |= IconMaskHint;
|
||||
hints->icon_mask = scr->applicationIconPixmap->mask;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(hints);
|
||||
XSetWMHints(scr->display, leader, hints);
|
||||
|
||||
XFree(hints);
|
||||
}
|
||||
scr->groupLeader = leader;
|
||||
}
|
||||
|
||||
+94
-93
@@ -19,19 +19,19 @@ typedef struct W_Balloon {
|
||||
WMFont *font;
|
||||
|
||||
WMHandlerID timer; /* timer for showing balloon */
|
||||
|
||||
|
||||
WMHandlerID noDelayTimer;
|
||||
|
||||
int delay;
|
||||
|
||||
Window forWindow; /* window for which the balloon
|
||||
* is being show in the moment */
|
||||
* is being show in the moment */
|
||||
|
||||
struct {
|
||||
WMAlignment alignment:2;
|
||||
unsigned enabled:1;
|
||||
WMAlignment alignment:2;
|
||||
unsigned enabled:1;
|
||||
|
||||
unsigned noDelay:1;
|
||||
unsigned noDelay:1;
|
||||
} flags;
|
||||
} Balloon;
|
||||
|
||||
@@ -63,8 +63,8 @@ W_CreateBalloon(WMScreen *scr)
|
||||
|
||||
bPtr->view = W_CreateUnmanagedTopView(scr);
|
||||
if (!bPtr->view) {
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
}
|
||||
bPtr->view->self = bPtr;
|
||||
|
||||
@@ -101,15 +101,15 @@ WMSetBalloonTextForView(char *text, WMView *view)
|
||||
WMScreen *scr = view->screen;
|
||||
|
||||
if (text) {
|
||||
oldText = WMHashInsert(scr->balloon->table, view, wstrdup(text));
|
||||
oldText = WMHashInsert(scr->balloon->table, view, wstrdup(text));
|
||||
} else {
|
||||
oldText = WMHashGet(scr->balloon->table, view);
|
||||
oldText = WMHashGet(scr->balloon->table, view);
|
||||
|
||||
WMHashRemove(scr->balloon->table, view);
|
||||
WMHashRemove(scr->balloon->table, view);
|
||||
}
|
||||
|
||||
if (oldText) {
|
||||
wfree(oldText);
|
||||
wfree(oldText);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,14 +118,14 @@ void
|
||||
WMSetBalloonFont(WMScreen *scr, WMFont *font)
|
||||
{
|
||||
Balloon *bPtr = scr->balloon;
|
||||
|
||||
|
||||
if (bPtr->font!=NULL)
|
||||
WMReleaseFont(bPtr->font);
|
||||
WMReleaseFont(bPtr->font);
|
||||
|
||||
if (font)
|
||||
bPtr->font = WMRetainFont(font);
|
||||
bPtr->font = WMRetainFont(font);
|
||||
else
|
||||
bPtr->font = NULL;
|
||||
bPtr->font = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ WMSetBalloonTextColor(WMScreen *scr, WMColor *color)
|
||||
Balloon *bPtr = scr->balloon;
|
||||
|
||||
if (bPtr->textColor)
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
|
||||
bPtr->textColor = WMRetainColor(color);
|
||||
}
|
||||
@@ -173,17 +173,17 @@ W_BalloonHandleLeaveView(WMView *view)
|
||||
Balloon *bPtr = view->screen->balloon;
|
||||
|
||||
if (bPtr->forWindow == view->window) {
|
||||
if (bPtr->view->flags.mapped) {
|
||||
W_UnmapView(bPtr->view);
|
||||
bPtr->noDelayTimer = WMAddTimerHandler(NO_DELAY_DELAY,
|
||||
clearNoDelay, bPtr);
|
||||
}
|
||||
if (bPtr->timer)
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
if (bPtr->view->flags.mapped) {
|
||||
W_UnmapView(bPtr->view);
|
||||
bPtr->noDelayTimer = WMAddTimerHandler(NO_DELAY_DELAY,
|
||||
clearNoDelay, bPtr);
|
||||
}
|
||||
if (bPtr->timer)
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
|
||||
bPtr->timer = NULL;
|
||||
bPtr->timer = NULL;
|
||||
|
||||
bPtr->forWindow = None;
|
||||
bPtr->forWindow = None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ W_BalloonHandleLeaveView(WMView *view)
|
||||
/*
|
||||
* botar balao perto do cursor
|
||||
* so mapear balao se o mouse ficar parado pelo delay
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
@@ -207,13 +207,13 @@ showBalloon(void *data)
|
||||
|
||||
text = WMHashGet(bPtr->table, view);
|
||||
if (!text)
|
||||
return;
|
||||
return;
|
||||
|
||||
XTranslateCoordinates(view->screen->display, view->window,
|
||||
view->screen->rootWin, 0, 0, &x, &y, &foo);
|
||||
view->screen->rootWin, 0, 0, &x, &y, &foo);
|
||||
|
||||
if (!bPtr->view->flags.realized)
|
||||
W_RealizeView(bPtr->view);
|
||||
W_RealizeView(bPtr->view);
|
||||
|
||||
showText(bPtr, x, y, view->size.width, view->size.height, text);
|
||||
|
||||
@@ -229,32 +229,32 @@ W_BalloonHandleEnterView(WMView *view)
|
||||
char *text;
|
||||
|
||||
if (!bPtr->flags.enabled)
|
||||
return;
|
||||
return;
|
||||
|
||||
text = WMHashGet(bPtr->table, view);
|
||||
if (!text) {
|
||||
if (bPtr->view->flags.realized)
|
||||
W_UnmapView(bPtr->view);
|
||||
if (bPtr->view->flags.realized)
|
||||
W_UnmapView(bPtr->view);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bPtr->timer)
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
|
||||
if (bPtr->noDelayTimer)
|
||||
WMDeleteTimerHandler(bPtr->noDelayTimer);
|
||||
WMDeleteTimerHandler(bPtr->noDelayTimer);
|
||||
bPtr->noDelayTimer = NULL;
|
||||
|
||||
bPtr->forWindow = view->window;
|
||||
|
||||
if (bPtr->flags.noDelay) {
|
||||
bPtr->timer = NULL;
|
||||
bPtr->timer = NULL;
|
||||
|
||||
showBalloon(view);
|
||||
showBalloon(view);
|
||||
} else {
|
||||
bPtr->timer = WMAddTimerHandler(bPtr->delay, showBalloon, view);
|
||||
bPtr->timer = WMAddTimerHandler(bPtr->delay, showBalloon, view);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
|
||||
|
||||
if (side & BOTTOM) {
|
||||
pt[0].y = y+h-1;
|
||||
pt[1].y = y+h-1+SPACE;
|
||||
pt[1].y = y+h-1+SPACE;
|
||||
pt[2].y = y+h-1;
|
||||
ipt[0].y = pt[0].y-1;
|
||||
ipt[1].y = pt[1].y-1;
|
||||
@@ -319,7 +319,7 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
|
||||
} else {
|
||||
pt[0].y = y;
|
||||
pt[1].y = y-SPACE;
|
||||
pt[2].y = y;
|
||||
pt[2].y = y;
|
||||
ipt[0].y = pt[0].y+1;
|
||||
ipt[1].y = pt[1].y+1;
|
||||
ipt[2].y = pt[2].y+1;
|
||||
@@ -329,15 +329,15 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
|
||||
w1 = WMAX(h, 21);
|
||||
|
||||
if (side & RIGHT) {
|
||||
pt[0].x = x+w-w1+2*w1/16;
|
||||
pt[0].x = x+w-w1+2*w1/16;
|
||||
pt[1].x = x+w-w1+11*w1/16;
|
||||
pt[2].x = x+w-w1+7*w1/16;
|
||||
ipt[0].x = x+1+w-w1+2*(w1-1)/16;
|
||||
ipt[0].x = x+1+w-w1+2*(w1-1)/16;
|
||||
ipt[1].x = x+1+w-w1+11*(w1-1)/16;
|
||||
ipt[2].x = x+1+w-w1+7*(w1-1)/16;
|
||||
/*ipt[0].x = pt[0].x+1;
|
||||
ipt[1].x = pt[1].x;
|
||||
ipt[2].x = pt[2].x;*/
|
||||
ipt[1].x = pt[1].x;
|
||||
ipt[2].x = pt[2].x;*/
|
||||
} else {
|
||||
pt[0].x = x+w1-2*w1/16;
|
||||
pt[1].x = x+w1-11*w1/16;
|
||||
@@ -346,8 +346,8 @@ drawBalloon(WMScreen *scr, Pixmap bitmap, Pixmap pix, int x, int y, int w,
|
||||
ipt[1].x = x-1+w1-11*(w1-1)/16;
|
||||
ipt[2].x = x-1+w1-7*(w1-1)/16;
|
||||
/*ipt[0].x = pt[0].x-1;
|
||||
ipt[1].x = pt[1].x;
|
||||
ipt[2].x = pt[2].x;*/
|
||||
ipt[1].x = pt[1].x;
|
||||
ipt[2].x = pt[2].x;*/
|
||||
}
|
||||
|
||||
XFillPolygon(dpy, bitmap, bgc, pt, 3, Convex, CoordModeOrigin);
|
||||
@@ -380,7 +380,7 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask)
|
||||
|
||||
bitmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE, 1);
|
||||
|
||||
XSetForeground(dpy, scr->monoGC, 0);
|
||||
XSetForeground(dpy, scr->monoGC, 0);
|
||||
XFillRectangle(dpy, bitmap, scr->monoGC, 0, 0, width+SPACE, height+SPACE);
|
||||
|
||||
pixmap = XCreatePixmap(dpy, scr->rootWin, width+SPACE, height+SPACE,
|
||||
@@ -390,9 +390,9 @@ makePixmap(WMScreen *scr, int width, int height, int side, Pixmap *mask)
|
||||
height+SPACE);
|
||||
|
||||
if (side & BOTTOM) {
|
||||
y = 0;
|
||||
y = 0;
|
||||
} else {
|
||||
y = SPACE;
|
||||
y = SPACE;
|
||||
}
|
||||
x = 0;
|
||||
|
||||
@@ -422,62 +422,62 @@ showText(Balloon *bPtr, int x, int y, int w, int h, char *text)
|
||||
int bx, by;
|
||||
|
||||
{
|
||||
int w;
|
||||
char *ptr, *ptr2;
|
||||
int w;
|
||||
char *ptr, *ptr2;
|
||||
|
||||
ptr2 = ptr = text;
|
||||
width = 0;
|
||||
while (ptr && ptr2) {
|
||||
ptr2 = strchr(ptr, '\n');
|
||||
if (ptr2) {
|
||||
w = WMWidthOfString(font, ptr, ptr2 - ptr);
|
||||
} else {
|
||||
w = WMWidthOfString(font, ptr, strlen(ptr));
|
||||
}
|
||||
if (w > width)
|
||||
width = w;
|
||||
ptr = ptr2 + 1;
|
||||
}
|
||||
ptr2 = ptr = text;
|
||||
width = 0;
|
||||
while (ptr && ptr2) {
|
||||
ptr2 = strchr(ptr, '\n');
|
||||
if (ptr2) {
|
||||
w = WMWidthOfString(font, ptr, ptr2 - ptr);
|
||||
} else {
|
||||
w = WMWidthOfString(font, ptr, strlen(ptr));
|
||||
}
|
||||
if (w > width)
|
||||
width = w;
|
||||
ptr = ptr2 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
width += 16;
|
||||
|
||||
textHeight = W_GetTextHeight(font, text, width, False);
|
||||
|
||||
|
||||
height = textHeight + 4;
|
||||
|
||||
|
||||
if (height < 16)
|
||||
height = 16;
|
||||
height = 16;
|
||||
if (width < height)
|
||||
width = height;
|
||||
width = height;
|
||||
|
||||
if (x + width > scr->rootView->size.width) {
|
||||
side = RIGHT;
|
||||
bx = x - width + w/2;
|
||||
if (bx < 0)
|
||||
bx = 0;
|
||||
side = RIGHT;
|
||||
bx = x - width + w/2;
|
||||
if (bx < 0)
|
||||
bx = 0;
|
||||
} else {
|
||||
side = LEFT;
|
||||
bx = x + w/2;
|
||||
side = LEFT;
|
||||
bx = x + w/2;
|
||||
}
|
||||
if (bx + width > scr->rootView->size.width)
|
||||
bx = scr->rootView->size.width - width;
|
||||
bx = scr->rootView->size.width - width;
|
||||
|
||||
if (y - (height + SPACE) < 0) {
|
||||
side |= TOP;
|
||||
by = y+h-1;
|
||||
ty = SPACE;
|
||||
side |= TOP;
|
||||
by = y+h-1;
|
||||
ty = SPACE;
|
||||
} else {
|
||||
side |= BOTTOM;
|
||||
by = y - (height + SPACE);
|
||||
ty = 0;
|
||||
side |= BOTTOM;
|
||||
by = y - (height + SPACE);
|
||||
ty = 0;
|
||||
}
|
||||
pixmap = makePixmap(scr, width, height, side, &mask);
|
||||
|
||||
W_PaintText(bPtr->view, pixmap, font, 8, ty + (height - textHeight)/2,
|
||||
width, bPtr->flags.alignment,
|
||||
bPtr->textColor ? bPtr->textColor : scr->black,
|
||||
False, text, strlen(text));
|
||||
width, bPtr->flags.alignment,
|
||||
bPtr->textColor ? bPtr->textColor : scr->black,
|
||||
False, text, strlen(text));
|
||||
|
||||
XSetWindowBackgroundPixmap(dpy, bPtr->view->window, pixmap);
|
||||
|
||||
@@ -487,7 +487,7 @@ showText(Balloon *bPtr, int x, int y, int w, int h, char *text)
|
||||
|
||||
#ifdef SHAPE
|
||||
XShapeCombineMask(dpy, bPtr->view->window, ShapeBounding, 0, 0, mask,
|
||||
ShapeSet);
|
||||
ShapeSet);
|
||||
#endif
|
||||
XFreePixmap(dpy, mask);
|
||||
|
||||
@@ -502,10 +502,10 @@ handleEvents(XEvent *event, void *data)
|
||||
{
|
||||
Balloon *bPtr = (Balloon*)data;
|
||||
|
||||
switch (event->type) {
|
||||
case DestroyNotify:
|
||||
destroyBalloon(bPtr);
|
||||
break;
|
||||
switch (event->type) {
|
||||
case DestroyNotify:
|
||||
destroyBalloon(bPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,15 +519,16 @@ destroyBalloon(Balloon *bPtr)
|
||||
e = WMEnumerateHashTable(bPtr->table);
|
||||
|
||||
while ((str = WMNextHashEnumeratorItem(&e))) {
|
||||
wfree(str);
|
||||
wfree(str);
|
||||
}
|
||||
WMFreeHashTable(bPtr->table);
|
||||
|
||||
if (bPtr->textColor)
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
|
||||
if (bPtr->font)
|
||||
WMReleaseFont(bPtr->font);
|
||||
WMReleaseFont(bPtr->font);
|
||||
|
||||
wfree(bPtr);
|
||||
}
|
||||
|
||||
+22
-22
@@ -60,8 +60,8 @@ WMCreateBox(WMWidget *parent)
|
||||
|
||||
bPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!bPtr->view) {
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
}
|
||||
bPtr->view->self = bPtr;
|
||||
|
||||
@@ -70,7 +70,7 @@ WMCreateBox(WMWidget *parent)
|
||||
bPtr->subviews = WMCreateArrayWithDestructor(2, wfree);
|
||||
|
||||
WMCreateEventHandler(bPtr->view, StructureNotifyMask,
|
||||
handleEvents, bPtr);
|
||||
handleEvents, bPtr);
|
||||
|
||||
WMResizeWidget(bPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
|
||||
@@ -149,19 +149,19 @@ rearrange(WMBox *box)
|
||||
eData.expands = 0;
|
||||
|
||||
if (box->horizontal) {
|
||||
eData.ye = box->borderWidth;
|
||||
eData.xe = WMWidgetWidth(box) - box->borderWidth;
|
||||
eData.h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
eData.total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
eData.ye = box->borderWidth;
|
||||
eData.xe = WMWidgetWidth(box) - box->borderWidth;
|
||||
eData.h = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
eData.total = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
} else {
|
||||
eData.xe = box->borderWidth;
|
||||
eData.ye = WMWidgetHeight(box) - box->borderWidth;
|
||||
eData.w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
eData.total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
eData.xe = box->borderWidth;
|
||||
eData.ye = WMWidgetHeight(box) - box->borderWidth;
|
||||
eData.w = WMWidgetWidth(box) - 2 * box->borderWidth;
|
||||
eData.total = WMWidgetHeight(box) - 2 * box->borderWidth;
|
||||
}
|
||||
|
||||
if (eData.w <= 0 || eData.h <= 0 || eData.total <= 0) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
WMMapArray(box->subviews, computeExpansion, &eData);
|
||||
@@ -181,7 +181,7 @@ WMSetBoxBorderWidth(WMBox *box, unsigned width)
|
||||
|
||||
void
|
||||
WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
int minSize, int maxSize, int space)
|
||||
int minSize, int maxSize, int space)
|
||||
{
|
||||
SubviewItem *subView;
|
||||
|
||||
@@ -203,7 +203,7 @@ WMAddBoxSubview(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
|
||||
void
|
||||
WMAddBoxSubviewAtEnd(WMBox *bPtr, WMView *view, Bool expand, Bool fill,
|
||||
int minSize, int maxSize, int space)
|
||||
int minSize, int maxSize, int space)
|
||||
{
|
||||
SubviewItem *subView;
|
||||
|
||||
@@ -272,14 +272,14 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
CHECK_CLASS(data, WC_Box);
|
||||
|
||||
switch (event->type) {
|
||||
case DestroyNotify:
|
||||
destroyBox(bPtr);
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
rearrange(bPtr);
|
||||
break;
|
||||
switch (event->type) {
|
||||
case DestroyNotify:
|
||||
destroyBox(bPtr);
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
rearrange(bPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+311
-310
File diff suppressed because it is too large.
Load diff
+273
-273
@@ -9,9 +9,9 @@ typedef struct W_Button {
|
||||
WMView *view;
|
||||
|
||||
char *caption;
|
||||
|
||||
|
||||
char *altCaption;
|
||||
|
||||
|
||||
WMFont *font;
|
||||
|
||||
WMColor *textColor;
|
||||
@@ -27,52 +27,52 @@ typedef struct W_Button {
|
||||
WMAction *action;
|
||||
|
||||
int tag;
|
||||
|
||||
|
||||
int groupIndex;
|
||||
|
||||
|
||||
float periodicDelay;
|
||||
float periodicInterval;
|
||||
|
||||
|
||||
WMHandlerID *timer; /* for continuous mode */
|
||||
|
||||
|
||||
struct {
|
||||
WMButtonType type:4;
|
||||
WMImagePosition imagePosition:4;
|
||||
WMAlignment alignment:2;
|
||||
WMButtonType type:4;
|
||||
WMImagePosition imagePosition:4;
|
||||
WMAlignment alignment:2;
|
||||
|
||||
unsigned int selected:1;
|
||||
unsigned int selected:1;
|
||||
|
||||
unsigned int enabled:1;
|
||||
unsigned int enabled:1;
|
||||
|
||||
unsigned int dimsWhenDisabled:1;
|
||||
|
||||
unsigned int bordered:1;
|
||||
unsigned int bordered:1;
|
||||
|
||||
unsigned int springLoaded:1;
|
||||
unsigned int springLoaded:1;
|
||||
|
||||
unsigned int pushIn:1; /* change relief while pushed */
|
||||
unsigned int pushIn:1; /* change relief while pushed */
|
||||
|
||||
unsigned int pushLight:1; /* highlight while pushed */
|
||||
unsigned int pushLight:1; /* highlight while pushed */
|
||||
|
||||
unsigned int pushChange:1; /* change caption while pushed */
|
||||
unsigned int pushChange:1; /* change caption while pushed */
|
||||
|
||||
unsigned int stateLight:1; /* state indicated by highlight */
|
||||
unsigned int stateLight:1; /* state indicated by highlight */
|
||||
|
||||
unsigned int stateChange:1; /* state indicated by caption change */
|
||||
unsigned int stateChange:1; /* state indicated by caption change */
|
||||
|
||||
unsigned int statePush:1; /* state indicated by relief */
|
||||
unsigned int statePush:1; /* state indicated by relief */
|
||||
|
||||
unsigned int continuous:1; /* continually perform action */
|
||||
unsigned int continuous:1; /* continually perform action */
|
||||
|
||||
unsigned int prevSelected:1;
|
||||
unsigned int prevSelected:1;
|
||||
|
||||
unsigned int pushed:1;
|
||||
unsigned int pushed:1;
|
||||
|
||||
unsigned int wasPushed:1;
|
||||
unsigned int wasPushed:1;
|
||||
|
||||
unsigned int redrawPending:1;
|
||||
unsigned int redrawPending:1;
|
||||
|
||||
unsigned int addedObserver:1;
|
||||
unsigned int addedObserver:1;
|
||||
} flags;
|
||||
} Button;
|
||||
|
||||
@@ -115,16 +115,16 @@ WMButton*
|
||||
WMCreateCustomButton(WMWidget *parent, int behaviourMask)
|
||||
{
|
||||
Button *bPtr;
|
||||
|
||||
|
||||
bPtr = wmalloc(sizeof(Button));
|
||||
memset(bPtr, 0, sizeof(Button));
|
||||
|
||||
bPtr->widgetClass = WC_Button;
|
||||
|
||||
|
||||
bPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!bPtr->view) {
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
}
|
||||
bPtr->view->self = bPtr;
|
||||
|
||||
@@ -146,11 +146,11 @@ WMCreateCustomButton(WMWidget *parent, int behaviourMask)
|
||||
bPtr->flags.dimsWhenDisabled = 1;
|
||||
|
||||
WMCreateEventHandler(bPtr->view, ExposureMask|StructureNotifyMask,
|
||||
handleEvents, bPtr);
|
||||
handleEvents, bPtr);
|
||||
|
||||
WMCreateEventHandler(bPtr->view, ButtonPressMask|ButtonReleaseMask
|
||||
|EnterWindowMask|LeaveWindowMask,
|
||||
handleActionEvents, bPtr);
|
||||
|EnterWindowMask|LeaveWindowMask,
|
||||
handleActionEvents, bPtr);
|
||||
|
||||
W_ResizeView(bPtr->view, DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT);
|
||||
bPtr->flags.alignment = DEFAULT_BUTTON_ALIGNMENT;
|
||||
@@ -166,68 +166,68 @@ WMCreateButton(WMWidget *parent, WMButtonType type)
|
||||
{
|
||||
W_Screen *scrPtr = W_VIEW(parent)->screen;
|
||||
Button *bPtr;
|
||||
|
||||
|
||||
switch (type) {
|
||||
case WBTMomentaryPush:
|
||||
bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask
|
||||
|WBBPushInMask|WBBPushLightMask);
|
||||
break;
|
||||
case WBTMomentaryPush:
|
||||
bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask
|
||||
|WBBPushInMask|WBBPushLightMask);
|
||||
break;
|
||||
|
||||
case WBTMomentaryChange:
|
||||
bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask
|
||||
|WBBPushChangeMask);
|
||||
break;
|
||||
|
||||
case WBTPushOnPushOff:
|
||||
bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStatePushMask
|
||||
|WBBStateLightMask);
|
||||
break;
|
||||
|
||||
case WBTToggle:
|
||||
bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStateChangeMask
|
||||
|WBBStatePushMask);
|
||||
break;
|
||||
case WBTMomentaryChange:
|
||||
bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask
|
||||
|WBBPushChangeMask);
|
||||
break;
|
||||
|
||||
case WBTOnOff:
|
||||
bPtr = WMCreateCustomButton(parent, WBBStateLightMask);
|
||||
break;
|
||||
case WBTPushOnPushOff:
|
||||
bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStatePushMask
|
||||
|WBBStateLightMask);
|
||||
break;
|
||||
|
||||
case WBTSwitch:
|
||||
bPtr = WMCreateCustomButton(parent, WBBStateChangeMask);
|
||||
bPtr->flags.bordered = 0;
|
||||
bPtr->image = WMRetainPixmap(scrPtr->checkButtonImageOff);
|
||||
bPtr->altImage = WMRetainPixmap(scrPtr->checkButtonImageOn);
|
||||
break;
|
||||
case WBTToggle:
|
||||
bPtr = WMCreateCustomButton(parent, WBBPushInMask|WBBStateChangeMask
|
||||
|WBBStatePushMask);
|
||||
break;
|
||||
|
||||
case WBTRadio:
|
||||
bPtr = WMCreateCustomButton(parent, WBBStateChangeMask);
|
||||
bPtr->flags.bordered = 0;
|
||||
bPtr->image = WMRetainPixmap(scrPtr->radioButtonImageOff);
|
||||
bPtr->altImage = WMRetainPixmap(scrPtr->radioButtonImageOn);
|
||||
break;
|
||||
case WBTOnOff:
|
||||
bPtr = WMCreateCustomButton(parent, WBBStateLightMask);
|
||||
break;
|
||||
|
||||
default:
|
||||
case WBTMomentaryLight:
|
||||
bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask
|
||||
|WBBPushLightMask);
|
||||
bPtr->flags.bordered = 1;
|
||||
break;
|
||||
case WBTSwitch:
|
||||
bPtr = WMCreateCustomButton(parent, WBBStateChangeMask);
|
||||
bPtr->flags.bordered = 0;
|
||||
bPtr->image = WMRetainPixmap(scrPtr->checkButtonImageOff);
|
||||
bPtr->altImage = WMRetainPixmap(scrPtr->checkButtonImageOn);
|
||||
break;
|
||||
|
||||
case WBTRadio:
|
||||
bPtr = WMCreateCustomButton(parent, WBBStateChangeMask);
|
||||
bPtr->flags.bordered = 0;
|
||||
bPtr->image = WMRetainPixmap(scrPtr->radioButtonImageOff);
|
||||
bPtr->altImage = WMRetainPixmap(scrPtr->radioButtonImageOn);
|
||||
break;
|
||||
|
||||
default:
|
||||
case WBTMomentaryLight:
|
||||
bPtr = WMCreateCustomButton(parent, WBBSpringLoadedMask
|
||||
|WBBPushLightMask);
|
||||
bPtr->flags.bordered = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bPtr->flags.type = type;
|
||||
|
||||
if (type==WBTRadio) {
|
||||
W_ResizeView(bPtr->view, DEFAULT_RADIO_WIDTH, DEFAULT_RADIO_HEIGHT);
|
||||
WMSetButtonText(bPtr, DEFAULT_RADIO_TEXT);
|
||||
bPtr->flags.alignment = DEFAULT_RADIO_ALIGNMENT;
|
||||
bPtr->flags.imagePosition = DEFAULT_RADIO_IMAGE_POSITION;
|
||||
W_ResizeView(bPtr->view, DEFAULT_RADIO_WIDTH, DEFAULT_RADIO_HEIGHT);
|
||||
WMSetButtonText(bPtr, DEFAULT_RADIO_TEXT);
|
||||
bPtr->flags.alignment = DEFAULT_RADIO_ALIGNMENT;
|
||||
bPtr->flags.imagePosition = DEFAULT_RADIO_IMAGE_POSITION;
|
||||
} else if (type==WBTSwitch) {
|
||||
W_ResizeView(bPtr->view, DEFAULT_SWITCH_WIDTH, DEFAULT_SWITCH_HEIGHT);
|
||||
WMSetButtonText(bPtr, DEFAULT_SWITCH_TEXT);
|
||||
bPtr->flags.alignment = DEFAULT_SWITCH_ALIGNMENT;
|
||||
bPtr->flags.imagePosition = DEFAULT_SWITCH_IMAGE_POSITION;
|
||||
W_ResizeView(bPtr->view, DEFAULT_SWITCH_WIDTH, DEFAULT_SWITCH_HEIGHT);
|
||||
WMSetButtonText(bPtr, DEFAULT_SWITCH_TEXT);
|
||||
bPtr->flags.alignment = DEFAULT_SWITCH_ALIGNMENT;
|
||||
bPtr->flags.imagePosition = DEFAULT_SWITCH_IMAGE_POSITION;
|
||||
}
|
||||
|
||||
|
||||
return bPtr;
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ updateDisabledMask(WMButton *bPtr)
|
||||
Display *dpy = scr->display;
|
||||
|
||||
if (bPtr->image) {
|
||||
XGCValues gcv;
|
||||
XGCValues gcv;
|
||||
|
||||
if (bPtr->dimage->mask) {
|
||||
XFreePixmap(dpy, bPtr->dimage->mask);
|
||||
@@ -287,25 +287,25 @@ void
|
||||
WMSetButtonImage(WMButton *bPtr, WMPixmap *image)
|
||||
{
|
||||
if (bPtr->image!=NULL)
|
||||
WMReleasePixmap(bPtr->image);
|
||||
WMReleasePixmap(bPtr->image);
|
||||
bPtr->image = WMRetainPixmap(image);
|
||||
|
||||
if (bPtr->dimage) {
|
||||
bPtr->dimage->pixmap = None;
|
||||
WMReleasePixmap(bPtr->dimage);
|
||||
bPtr->dimage = NULL;
|
||||
bPtr->dimage->pixmap = None;
|
||||
WMReleasePixmap(bPtr->dimage);
|
||||
bPtr->dimage = NULL;
|
||||
}
|
||||
|
||||
if (image) {
|
||||
bPtr->dimage = WMCreatePixmapFromXPixmaps(WMWidgetScreen(bPtr),
|
||||
image->pixmap, None,
|
||||
image->width, image->height,
|
||||
image->depth);
|
||||
updateDisabledMask(bPtr);
|
||||
bPtr->dimage = WMCreatePixmapFromXPixmaps(WMWidgetScreen(bPtr),
|
||||
image->pixmap, None,
|
||||
image->width, image->height,
|
||||
image->depth);
|
||||
updateDisabledMask(bPtr);
|
||||
}
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,12 +314,12 @@ void
|
||||
WMSetButtonAltImage(WMButton *bPtr, WMPixmap *image)
|
||||
{
|
||||
if (bPtr->altImage!=NULL)
|
||||
WMReleasePixmap(bPtr->altImage);
|
||||
WMReleasePixmap(bPtr->altImage);
|
||||
bPtr->altImage = WMRetainPixmap(image);
|
||||
|
||||
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,10 +328,10 @@ void
|
||||
WMSetButtonImagePosition(WMButton *bPtr, WMImagePosition position)
|
||||
{
|
||||
bPtr->flags.imagePosition = position;
|
||||
|
||||
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,10 +342,10 @@ void
|
||||
WMSetButtonTextAlignment(WMButton *bPtr, WMAlignment alignment)
|
||||
{
|
||||
bPtr->flags.alignment = alignment;
|
||||
|
||||
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,17 +353,17 @@ void
|
||||
WMSetButtonText(WMButton *bPtr, char *text)
|
||||
{
|
||||
if (bPtr->caption)
|
||||
wfree(bPtr->caption);
|
||||
wfree(bPtr->caption);
|
||||
|
||||
if (text!=NULL) {
|
||||
bPtr->caption = wstrdup(text);
|
||||
bPtr->caption = wstrdup(text);
|
||||
} else {
|
||||
bPtr->caption = NULL;
|
||||
bPtr->caption = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,16 +372,16 @@ void
|
||||
WMSetButtonAltText(WMButton *bPtr, char *text)
|
||||
{
|
||||
if (bPtr->altCaption)
|
||||
wfree(bPtr->altCaption);
|
||||
|
||||
wfree(bPtr->altCaption);
|
||||
|
||||
if (text!=NULL) {
|
||||
bPtr->altCaption = wstrdup(text);
|
||||
bPtr->altCaption = wstrdup(text);
|
||||
} else {
|
||||
bPtr->altCaption = NULL;
|
||||
bPtr->altCaption = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ void
|
||||
WMSetButtonTextColor(WMButton *bPtr, WMColor *color)
|
||||
{
|
||||
if (bPtr->textColor)
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
|
||||
bPtr->textColor = WMRetainColor(color);
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void
|
||||
WMSetButtonAltTextColor(WMButton *bPtr, WMColor *color)
|
||||
{
|
||||
if (bPtr->altTextColor)
|
||||
WMReleaseColor(bPtr->altTextColor);
|
||||
WMReleaseColor(bPtr->altTextColor);
|
||||
|
||||
bPtr->altTextColor = WMRetainColor(color);
|
||||
}
|
||||
@@ -410,7 +410,7 @@ void
|
||||
WMSetButtonDisabledTextColor(WMButton *bPtr, WMColor *color)
|
||||
{
|
||||
if (bPtr->disTextColor)
|
||||
WMReleaseColor(bPtr->disTextColor);
|
||||
WMReleaseColor(bPtr->disTextColor);
|
||||
|
||||
bPtr->disTextColor = WMRetainColor(color);
|
||||
}
|
||||
@@ -420,12 +420,12 @@ void
|
||||
WMSetButtonSelected(WMButton *bPtr, int isSelected)
|
||||
{
|
||||
bPtr->flags.selected = isSelected ? 1 : 0;
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
}
|
||||
paintButton(bPtr);
|
||||
}
|
||||
if (bPtr->groupIndex > 0)
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -433,7 +433,7 @@ int
|
||||
WMGetButtonSelected(WMButton *bPtr)
|
||||
{
|
||||
CHECK_CLASS(bPtr, WC_Button);
|
||||
|
||||
|
||||
return bPtr->flags.selected;
|
||||
}
|
||||
|
||||
@@ -442,9 +442,9 @@ void
|
||||
WMSetButtonBordered(WMButton *bPtr, int isBordered)
|
||||
{
|
||||
bPtr->flags.bordered = isBordered;
|
||||
|
||||
|
||||
if (bPtr->view->flags.realized) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ void
|
||||
WMSetButtonFont(WMButton *bPtr, WMFont *font)
|
||||
{
|
||||
if (bPtr->font)
|
||||
WMReleaseFont(bPtr->font);
|
||||
WMReleaseFont(bPtr->font);
|
||||
|
||||
bPtr->font = WMRetainFont(font);
|
||||
}
|
||||
@@ -465,7 +465,7 @@ WMSetButtonEnabled(WMButton *bPtr, Bool flag)
|
||||
bPtr->flags.enabled = ((flag==0) ? 0 : 1);
|
||||
|
||||
if (bPtr->view->flags.mapped) {
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,28 +501,28 @@ WMPerformButtonClick(WMButton *bPtr)
|
||||
CHECK_CLASS(bPtr, WC_Button);
|
||||
|
||||
if (!bPtr->flags.enabled)
|
||||
return;
|
||||
return;
|
||||
|
||||
bPtr->flags.pushed = 1;
|
||||
bPtr->flags.selected = 1;
|
||||
|
||||
|
||||
if (bPtr->view->flags.mapped) {
|
||||
paintButton(bPtr);
|
||||
XFlush(WMScreenDisplay(WMWidgetScreen(bPtr)));
|
||||
wusleep(20000);
|
||||
paintButton(bPtr);
|
||||
XFlush(WMScreenDisplay(WMWidgetScreen(bPtr)));
|
||||
wusleep(20000);
|
||||
}
|
||||
|
||||
|
||||
bPtr->flags.pushed = 0;
|
||||
|
||||
|
||||
if (bPtr->groupIndex > 0) {
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintButton(bPtr);
|
||||
paintButton(bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -531,9 +531,9 @@ void
|
||||
WMSetButtonAction(WMButton *bPtr, WMAction *action, void *clientData)
|
||||
{
|
||||
CHECK_CLASS(bPtr, WC_Button);
|
||||
|
||||
|
||||
bPtr->action = action;
|
||||
|
||||
|
||||
bPtr->clientData = clientData;
|
||||
}
|
||||
|
||||
@@ -547,11 +547,11 @@ radioPushObserver(void *observerData, WMNotification *notification)
|
||||
WMButton *pushedButton = (WMButton*)WMGetNotificationObject(notification);
|
||||
|
||||
if (bPtr!=pushedButton && pushedButton->groupIndex == bPtr->groupIndex
|
||||
&& bPtr->groupIndex!=0) {
|
||||
if (bPtr->flags.selected) {
|
||||
bPtr->flags.selected = 0;
|
||||
paintButton(bPtr);
|
||||
}
|
||||
&& bPtr->groupIndex!=0) {
|
||||
if (bPtr->flags.selected) {
|
||||
bPtr->flags.selected = 0;
|
||||
paintButton(bPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -561,23 +561,23 @@ void
|
||||
WMGroupButtons(WMButton *bPtr, WMButton *newMember)
|
||||
{
|
||||
static int tagIndex = 0;
|
||||
|
||||
|
||||
CHECK_CLASS(bPtr, WC_Button);
|
||||
CHECK_CLASS(newMember, WC_Button);
|
||||
|
||||
if (!bPtr->flags.addedObserver) {
|
||||
WMAddNotificationObserver(radioPushObserver, bPtr,
|
||||
WMPushedRadioNotification, NULL);
|
||||
bPtr->flags.addedObserver = 1;
|
||||
WMAddNotificationObserver(radioPushObserver, bPtr,
|
||||
WMPushedRadioNotification, NULL);
|
||||
bPtr->flags.addedObserver = 1;
|
||||
}
|
||||
if (!newMember->flags.addedObserver) {
|
||||
WMAddNotificationObserver(radioPushObserver, newMember,
|
||||
WMPushedRadioNotification, NULL);
|
||||
newMember->flags.addedObserver = 1;
|
||||
WMAddNotificationObserver(radioPushObserver, newMember,
|
||||
WMPushedRadioNotification, NULL);
|
||||
newMember->flags.addedObserver = 1;
|
||||
}
|
||||
|
||||
|
||||
if (bPtr->groupIndex==0) {
|
||||
bPtr->groupIndex = ++tagIndex;
|
||||
bPtr->groupIndex = ++tagIndex;
|
||||
}
|
||||
newMember->groupIndex = bPtr->groupIndex;
|
||||
}
|
||||
@@ -588,8 +588,8 @@ WMSetButtonContinuous(WMButton *bPtr, Bool flag)
|
||||
{
|
||||
bPtr->flags.continuous = ((flag==0) ? 0 : 1);
|
||||
if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,14 +626,14 @@ paintButton(Button *bPtr)
|
||||
}
|
||||
|
||||
if (bPtr->flags.enabled || !bPtr->dimage)
|
||||
image = bPtr->image;
|
||||
image = bPtr->image;
|
||||
else
|
||||
image = bPtr->dimage;
|
||||
image = bPtr->dimage;
|
||||
offset = 0;
|
||||
if (bPtr->flags.bordered)
|
||||
relief = WRRaised;
|
||||
relief = WRRaised;
|
||||
else
|
||||
relief = WRFlat;
|
||||
relief = WRFlat;
|
||||
|
||||
if (bPtr->flags.selected) {
|
||||
if (bPtr->flags.stateLight) {
|
||||
@@ -641,45 +641,45 @@ paintButton(Button *bPtr)
|
||||
textColor = scrPtr->black;
|
||||
}
|
||||
|
||||
if (bPtr->flags.stateChange) {
|
||||
if (bPtr->altCaption)
|
||||
caption = bPtr->altCaption;
|
||||
if (bPtr->altImage)
|
||||
image = bPtr->altImage;
|
||||
if (bPtr->flags.stateChange) {
|
||||
if (bPtr->altCaption)
|
||||
caption = bPtr->altCaption;
|
||||
if (bPtr->altImage)
|
||||
image = bPtr->altImage;
|
||||
if (bPtr->altTextColor)
|
||||
textColor = bPtr->altTextColor;
|
||||
}
|
||||
|
||||
if (bPtr->flags.statePush && bPtr->flags.bordered) {
|
||||
relief = WRSunken;
|
||||
offset = 1;
|
||||
}
|
||||
if (bPtr->flags.statePush && bPtr->flags.bordered) {
|
||||
relief = WRSunken;
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (bPtr->flags.pushed) {
|
||||
if (bPtr->flags.pushIn) {
|
||||
relief = WRPushed;
|
||||
offset = 1;
|
||||
}
|
||||
if (bPtr->flags.pushIn) {
|
||||
relief = WRPushed;
|
||||
offset = 1;
|
||||
}
|
||||
if (bPtr->flags.pushLight) {
|
||||
backColor = scrPtr->white;
|
||||
textColor = scrPtr->black;
|
||||
}
|
||||
|
||||
if (bPtr->flags.pushChange) {
|
||||
if (bPtr->altCaption)
|
||||
caption = bPtr->altCaption;
|
||||
if (bPtr->altImage)
|
||||
image = bPtr->altImage;
|
||||
if (bPtr->flags.pushChange) {
|
||||
if (bPtr->altCaption)
|
||||
caption = bPtr->altCaption;
|
||||
if (bPtr->altImage)
|
||||
image = bPtr->altImage;
|
||||
if (bPtr->altTextColor)
|
||||
textColor = bPtr->altTextColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
W_PaintTextAndImage(bPtr->view, True, textColor,
|
||||
(bPtr->font!=NULL ? bPtr->font : scrPtr->normalFont),
|
||||
relief, caption, bPtr->flags.alignment, image,
|
||||
bPtr->flags.imagePosition, backColor, offset);
|
||||
(bPtr->font!=NULL ? bPtr->font : scrPtr->normalFont),
|
||||
relief, caption, bPtr->flags.alignment, image,
|
||||
bPtr->flags.imagePosition, backColor, offset);
|
||||
}
|
||||
|
||||
|
||||
@@ -693,29 +693,29 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintButton(bPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyButton(bPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintButton(bPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyButton(bPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static void
|
||||
autoRepeat(void *data)
|
||||
{
|
||||
Button *bPtr = (Button*)data;
|
||||
|
||||
if (bPtr->action && bPtr->flags.pushed)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
|
||||
bPtr->timer = WMAddTimerHandler((int)(bPtr->periodicInterval*1000),
|
||||
autoRepeat, bPtr);
|
||||
autoRepeat, bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -728,80 +728,80 @@ handleActionEvents(XEvent *event, void *data)
|
||||
CHECK_CLASS(data, WC_Button);
|
||||
|
||||
if (!bPtr->flags.enabled)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
switch (event->type) {
|
||||
case EnterNotify:
|
||||
if (bPtr->groupIndex == 0) {
|
||||
bPtr->flags.pushed = bPtr->flags.wasPushed;
|
||||
if (bPtr->flags.pushed) {
|
||||
bPtr->flags.selected = !bPtr->flags.prevSelected;
|
||||
dopaint = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EnterNotify:
|
||||
if (bPtr->groupIndex == 0) {
|
||||
bPtr->flags.pushed = bPtr->flags.wasPushed;
|
||||
if (bPtr->flags.pushed) {
|
||||
bPtr->flags.selected = !bPtr->flags.prevSelected;
|
||||
dopaint = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LeaveNotify:
|
||||
if (bPtr->groupIndex == 0) {
|
||||
bPtr->flags.wasPushed = bPtr->flags.pushed;
|
||||
if (bPtr->flags.pushed) {
|
||||
bPtr->flags.selected = bPtr->flags.prevSelected;
|
||||
dopaint = 1;
|
||||
}
|
||||
bPtr->flags.pushed = 0;
|
||||
}
|
||||
break;
|
||||
case LeaveNotify:
|
||||
if (bPtr->groupIndex == 0) {
|
||||
bPtr->flags.wasPushed = bPtr->flags.pushed;
|
||||
if (bPtr->flags.pushed) {
|
||||
bPtr->flags.selected = bPtr->flags.prevSelected;
|
||||
dopaint = 1;
|
||||
}
|
||||
bPtr->flags.pushed = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
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) {
|
||||
bPtr->flags.selected = 1;
|
||||
dopaint = 1;
|
||||
break;
|
||||
}
|
||||
bPtr->flags.selected = !bPtr->flags.selected;
|
||||
dopaint = 1;
|
||||
|
||||
if (bPtr->flags.continuous && !bPtr->timer) {
|
||||
bPtr->timer = WMAddTimerHandler((int)(bPtr->periodicDelay*1000),
|
||||
autoRepeat, bPtr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event->xbutton.button == Button1) {
|
||||
if (bPtr->flags.pushed) {
|
||||
if (bPtr->groupIndex==0 ||
|
||||
(bPtr->flags.selected && bPtr->groupIndex > 0))
|
||||
doclick = 1;
|
||||
dopaint = 1;
|
||||
if (bPtr->flags.springLoaded) {
|
||||
bPtr->flags.selected = bPtr->flags.prevSelected;
|
||||
}
|
||||
}
|
||||
bPtr->flags.pushed = 0;
|
||||
}
|
||||
if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
break;
|
||||
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) {
|
||||
bPtr->flags.selected = 1;
|
||||
dopaint = 1;
|
||||
break;
|
||||
}
|
||||
bPtr->flags.selected = !bPtr->flags.selected;
|
||||
dopaint = 1;
|
||||
|
||||
if (bPtr->flags.continuous && !bPtr->timer) {
|
||||
bPtr->timer = WMAddTimerHandler((int)(bPtr->periodicDelay*1000),
|
||||
autoRepeat, bPtr);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event->xbutton.button == Button1) {
|
||||
if (bPtr->flags.pushed) {
|
||||
if (bPtr->groupIndex==0 ||
|
||||
(bPtr->flags.selected && bPtr->groupIndex > 0))
|
||||
doclick = 1;
|
||||
dopaint = 1;
|
||||
if (bPtr->flags.springLoaded) {
|
||||
bPtr->flags.selected = bPtr->flags.prevSelected;
|
||||
}
|
||||
}
|
||||
bPtr->flags.pushed = 0;
|
||||
}
|
||||
if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (dopaint)
|
||||
paintButton(bPtr);
|
||||
|
||||
if (doclick) {
|
||||
if (bPtr->flags.selected && bPtr->groupIndex > 0) {
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
paintButton(bPtr);
|
||||
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
if (doclick) {
|
||||
if (bPtr->flags.selected && bPtr->groupIndex > 0) {
|
||||
WMPostNotificationName(WMPushedRadioNotification, bPtr, NULL);
|
||||
}
|
||||
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -811,20 +811,20 @@ static void
|
||||
destroyButton(Button *bPtr)
|
||||
{
|
||||
if (bPtr->flags.addedObserver) {
|
||||
WMRemoveNotificationObserver(bPtr);
|
||||
WMRemoveNotificationObserver(bPtr);
|
||||
}
|
||||
|
||||
if (bPtr->timer)
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
|
||||
if (bPtr->font)
|
||||
WMReleaseFont(bPtr->font);
|
||||
|
||||
WMReleaseFont(bPtr->font);
|
||||
|
||||
if (bPtr->caption)
|
||||
wfree(bPtr->caption);
|
||||
wfree(bPtr->caption);
|
||||
|
||||
if (bPtr->altCaption)
|
||||
wfree(bPtr->altCaption);
|
||||
wfree(bPtr->altCaption);
|
||||
|
||||
if (bPtr->textColor)
|
||||
WMReleaseColor(bPtr->textColor);
|
||||
@@ -836,16 +836,16 @@ destroyButton(Button *bPtr)
|
||||
WMReleaseColor(bPtr->disTextColor);
|
||||
|
||||
if (bPtr->image)
|
||||
WMReleasePixmap(bPtr->image);
|
||||
WMReleasePixmap(bPtr->image);
|
||||
|
||||
if (bPtr->dimage) {
|
||||
/* yuck.. kluge */
|
||||
bPtr->dimage->pixmap = None;
|
||||
/* yuck.. kluge */
|
||||
bPtr->dimage->pixmap = None;
|
||||
|
||||
WMReleasePixmap(bPtr->dimage);
|
||||
WMReleasePixmap(bPtr->dimage);
|
||||
}
|
||||
if (bPtr->altImage)
|
||||
WMReleasePixmap(bPtr->altImage);
|
||||
WMReleasePixmap(bPtr->altImage);
|
||||
|
||||
wfree(bPtr);
|
||||
}
|
||||
|
||||
+99
-99
@@ -8,12 +8,12 @@
|
||||
#define LIGHT_STIPPLE_WIDTH 4
|
||||
#define LIGHT_STIPPLE_HEIGHT 4
|
||||
static unsigned char LIGHT_STIPPLE_BITS[] = {
|
||||
0x05, 0x0a, 0x05, 0x0a};
|
||||
0x05, 0x0a, 0x05, 0x0a};
|
||||
|
||||
#define DARK_STIPPLE_WIDTH 4
|
||||
#define DARK_STIPPLE_HEIGHT 4
|
||||
static unsigned char DARK_STIPPLE_BITS[] = {
|
||||
0x0a, 0x04, 0x0a, 0x01};
|
||||
0x0a, 0x04, 0x0a, 0x01};
|
||||
|
||||
|
||||
static WMColor *createRGBAColor(WMScreen *scr, unsigned short red,
|
||||
@@ -28,8 +28,8 @@ static WMColor *createRGBAColor(WMScreen *scr, unsigned short red,
|
||||
*/
|
||||
|
||||
static WMColor*
|
||||
findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, unsigned short alpha)
|
||||
findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, unsigned short alpha)
|
||||
{
|
||||
WMColor *color;
|
||||
XColor xcolor;
|
||||
@@ -41,10 +41,10 @@ findCloseColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
rcolor.alpha = alpha>>8;
|
||||
|
||||
if (!RGetClosestXColor(scr->rcontext, &rcolor, &xcolor))
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
if (!XAllocColor(scr->display, scr->colormap, &xcolor))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
color = wmalloc(sizeof(WMColor));
|
||||
|
||||
@@ -72,7 +72,7 @@ createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
xcolor.blue = blue;
|
||||
xcolor.flags = DoRed|DoGreen|DoBlue;
|
||||
if (!XAllocColor(scr->display, scr->colormap, &xcolor))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
color = wmalloc(sizeof(WMColor));
|
||||
|
||||
@@ -88,16 +88,16 @@ createRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
|
||||
|
||||
WMColor*
|
||||
WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, Bool exact)
|
||||
WMCreateRGBColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, Bool exact)
|
||||
{
|
||||
WMColor *color = NULL;
|
||||
|
||||
if (!exact || !(color=createRGBAColor(scr, red, green, blue, 0xffff))) {
|
||||
color = findCloseColor(scr, red, green, blue, 0xffff);
|
||||
color = findCloseColor(scr, red, green, blue, 0xffff);
|
||||
}
|
||||
if (!color)
|
||||
color = WMBlackColor(scr);
|
||||
color = WMBlackColor(scr);
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -108,12 +108,12 @@ WMCreateRGBAColor(WMScreen *scr, unsigned short red, unsigned short green,
|
||||
unsigned short blue, unsigned short alpha, Bool exact)
|
||||
{
|
||||
WMColor *color = NULL;
|
||||
|
||||
|
||||
if (!exact || !(color=createRGBAColor(scr, red, green, blue, alpha))) {
|
||||
color = findCloseColor(scr, red, green, blue, alpha);
|
||||
color = findCloseColor(scr, red, green, blue, alpha);
|
||||
}
|
||||
if (!color)
|
||||
color = WMBlackColor(scr);
|
||||
color = WMBlackColor(scr);
|
||||
|
||||
return color;
|
||||
}
|
||||
@@ -124,16 +124,16 @@ WMCreateNamedColor(WMScreen *scr, char *name, Bool exact)
|
||||
{
|
||||
WMColor *color;
|
||||
XColor xcolor;
|
||||
|
||||
|
||||
if (!XParseColor(scr->display, scr->colormap, name, &xcolor))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (scr->visual->class == TrueColor)
|
||||
exact = True;
|
||||
exact = True;
|
||||
|
||||
if (!exact || !(color=createRGBAColor(scr, xcolor.red, xcolor.green,
|
||||
xcolor.blue, 0xffff))) {
|
||||
color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff);
|
||||
color = findCloseColor(scr, xcolor.red, xcolor.green, xcolor.blue, 0xffff);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
@@ -144,9 +144,9 @@ WMColor*
|
||||
WMRetainColor(WMColor *color)
|
||||
{
|
||||
assert(color!=NULL);
|
||||
|
||||
|
||||
color->refCount++;
|
||||
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -155,13 +155,13 @@ void
|
||||
WMReleaseColor(WMColor *color)
|
||||
{
|
||||
color->refCount--;
|
||||
|
||||
|
||||
if (color->refCount < 1) {
|
||||
XFreeColors(color->screen->display, color->screen->colormap,
|
||||
&(color->color.pixel), 1, 0);
|
||||
if (color->gc)
|
||||
XFreeGC(color->screen->display, color->gc);
|
||||
wfree(color);
|
||||
XFreeColors(color->screen->display, color->screen->colormap,
|
||||
&(color->color.pixel), 1, 0);
|
||||
if (color->gc)
|
||||
XFreeGC(color->screen->display, color->gc);
|
||||
wfree(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +175,10 @@ WMSetColorAlpha(WMColor *color, unsigned short alpha)
|
||||
|
||||
void
|
||||
WMPaintColorSwatch(WMColor *color, Drawable d, int x, int y,
|
||||
unsigned int width, unsigned int height)
|
||||
unsigned int width, unsigned int height)
|
||||
{
|
||||
XFillRectangle(color->screen->display, d, WMColorGC(color),
|
||||
x, y, width, height);
|
||||
XFillRectangle(color->screen->display, d, WMColorGC(color),
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,20 +193,20 @@ GC
|
||||
WMColorGC(WMColor *color)
|
||||
{
|
||||
if (!color->gc) {
|
||||
XGCValues gcv;
|
||||
WMScreen *scr = color->screen;
|
||||
XGCValues gcv;
|
||||
WMScreen *scr = color->screen;
|
||||
|
||||
gcv.foreground = color->color.pixel;
|
||||
gcv.graphics_exposures = False;
|
||||
color->gc = XCreateGC(scr->display, scr->rcontext->drawable,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
gcv.foreground = color->color.pixel;
|
||||
gcv.graphics_exposures = False;
|
||||
color->gc = XCreateGC(scr->display, scr->rcontext->drawable,
|
||||
GCForeground|GCGraphicsExposures, &gcv);
|
||||
}
|
||||
|
||||
return color->gc;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
WMSetColorInGC(WMColor *color, GC gc)
|
||||
{
|
||||
XSetForeground(color->screen->display, gc, color->color.pixel);
|
||||
@@ -219,9 +219,9 @@ WMColor*
|
||||
WMWhiteColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->white) {
|
||||
scr->white = WMCreateRGBColor(scr, 0xffff, 0xffff, 0xffff, True);
|
||||
if (!scr->white->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("white"));
|
||||
scr->white = WMCreateRGBColor(scr, 0xffff, 0xffff, 0xffff, True);
|
||||
if (!scr->white->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("white"));
|
||||
}
|
||||
return WMRetainColor(scr->white);
|
||||
}
|
||||
@@ -231,9 +231,9 @@ WMColor*
|
||||
WMBlackColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->black) {
|
||||
scr->black = WMCreateRGBColor(scr, 0, 0, 0, True);
|
||||
if (!scr->black->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("black"));
|
||||
scr->black = WMCreateRGBColor(scr, 0, 0, 0, True);
|
||||
if (!scr->black->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("black"));
|
||||
}
|
||||
return WMRetainColor(scr->black);
|
||||
}
|
||||
@@ -244,37 +244,37 @@ WMColor*
|
||||
WMGrayColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->gray) {
|
||||
WMColor *color;
|
||||
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
WMColor *color;
|
||||
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH,
|
||||
LIGHT_STIPPLE_HEIGHT);
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
|
||||
color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff);
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
LIGHT_STIPPLE_BITS, LIGHT_STIPPLE_WIDTH,
|
||||
LIGHT_STIPPLE_HEIGHT);
|
||||
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
color = createRGBAColor(scr, 0xffff, 0xffff, 0xffff, 0xffff);
|
||||
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0xaeba, 0xaaaa, 0xaeba, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("gray"));
|
||||
}
|
||||
scr->gray = color;
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0xaeba, 0xaaaa, 0xaeba, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("gray"));
|
||||
}
|
||||
scr->gray = color;
|
||||
}
|
||||
return WMRetainColor(scr->gray);
|
||||
}
|
||||
@@ -285,37 +285,37 @@ WMColor*
|
||||
WMDarkGrayColor(WMScreen *scr)
|
||||
{
|
||||
if (!scr->darkGray) {
|
||||
WMColor *color;
|
||||
WMColor *color;
|
||||
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
if (scr->depth == 1) {
|
||||
Pixmap stipple;
|
||||
WMColor *white = WMWhiteColor(scr);
|
||||
WMColor *black = WMBlackColor(scr);
|
||||
XGCValues gcv;
|
||||
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH,
|
||||
DARK_STIPPLE_HEIGHT);
|
||||
stipple = XCreateBitmapFromData(scr->display, W_DRAWABLE(scr),
|
||||
DARK_STIPPLE_BITS, DARK_STIPPLE_WIDTH,
|
||||
DARK_STIPPLE_HEIGHT);
|
||||
|
||||
color = createRGBAColor(scr, 0, 0, 0, 0xffff);
|
||||
color = createRGBAColor(scr, 0, 0, 0, 0xffff);
|
||||
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
gcv.foreground = white->color.pixel;
|
||||
gcv.background = black->color.pixel;
|
||||
gcv.fill_style = FillStippled;
|
||||
gcv.stipple = stipple;
|
||||
color->gc = XCreateGC(scr->display, W_DRAWABLE(scr), GCForeground
|
||||
|GCBackground|GCStipple|GCFillStyle
|
||||
|GCGraphicsExposures, &gcv);
|
||||
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0x5144, 0x5555, 0x5144, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("dark gray"));
|
||||
}
|
||||
scr->darkGray = color;
|
||||
XFreePixmap(scr->display, stipple);
|
||||
WMReleaseColor(white);
|
||||
WMReleaseColor(black);
|
||||
} else {
|
||||
color = WMCreateRGBColor(scr, 0x5144, 0x5555, 0x5144, True);
|
||||
if (!color->flags.exact)
|
||||
wwarning(_("could not allocate %s color"), _("dark gray"));
|
||||
}
|
||||
scr->darkGray = color;
|
||||
}
|
||||
return WMRetainColor(scr->darkGray);
|
||||
}
|
||||
@@ -353,10 +353,10 @@ char*
|
||||
WMGetColorRGBDescription(WMColor *color)
|
||||
{
|
||||
char *str = wmalloc(32);
|
||||
|
||||
|
||||
sprintf(str, "#%02x%02x%02x", color->color.red>>8, color->color.green>>8,
|
||||
color->color.blue>>8);
|
||||
|
||||
color->color.blue>>8);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
+1521
-1520
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -16,9 +16,9 @@ static unsigned long eventMasks[] = {
|
||||
ButtonPressMask, /* ButtonPress */
|
||||
ButtonReleaseMask, /* ButtonRelease */
|
||||
PointerMotionMask|PointerMotionHintMask|ButtonMotionMask
|
||||
|Button1MotionMask|Button2MotionMask|Button3MotionMask
|
||||
|Button4MotionMask|Button5MotionMask,
|
||||
/* MotionNotify */
|
||||
|Button1MotionMask|Button2MotionMask|Button3MotionMask
|
||||
|Button4MotionMask|Button5MotionMask,
|
||||
/* MotionNotify */
|
||||
EnterWindowMask, /* EnterNotify */
|
||||
LeaveWindowMask, /* LeaveNotify */
|
||||
FocusChangeMask, /* FocusIn */
|
||||
|
||||
+189
-189
@@ -16,18 +16,18 @@
|
||||
|
||||
typedef struct W_FilePanel {
|
||||
WMWindow *win;
|
||||
|
||||
|
||||
WMLabel *iconLabel;
|
||||
WMLabel *titleLabel;
|
||||
|
||||
|
||||
WMFrame *line;
|
||||
|
||||
WMLabel *nameLabel;
|
||||
WMBrowser *browser;
|
||||
|
||||
|
||||
WMButton *okButton;
|
||||
WMButton *cancelButton;
|
||||
|
||||
|
||||
WMButton *homeButton;
|
||||
WMButton *trashcanButton;
|
||||
WMButton *createDirButton;
|
||||
@@ -37,20 +37,20 @@ typedef struct W_FilePanel {
|
||||
WMView *accessoryView;
|
||||
|
||||
WMTextField *fileField;
|
||||
|
||||
|
||||
char **fileTypes;
|
||||
|
||||
struct {
|
||||
unsigned int canExit:1;
|
||||
unsigned int canceled:1; /* clicked on cancel */
|
||||
unsigned int filtered:1;
|
||||
unsigned int canChooseFiles:1;
|
||||
unsigned int canChooseDirectories:1;
|
||||
unsigned int autoCompletion:1;
|
||||
unsigned int showAllFiles:1;
|
||||
unsigned int canFreeFileTypes:1;
|
||||
unsigned int fileMustExist:1;
|
||||
unsigned int panelType:1;
|
||||
unsigned int canExit:1;
|
||||
unsigned int canceled:1; /* clicked on cancel */
|
||||
unsigned int filtered:1;
|
||||
unsigned int canChooseFiles:1;
|
||||
unsigned int canChooseDirectories:1;
|
||||
unsigned int autoCompletion:1;
|
||||
unsigned int showAllFiles:1;
|
||||
unsigned int canFreeFileTypes:1;
|
||||
unsigned int fileMustExist:1;
|
||||
unsigned int panelType:1;
|
||||
} flags;
|
||||
} W_FilePanel;
|
||||
|
||||
@@ -67,7 +67,7 @@ static void browserClick();
|
||||
static void browserDClick();
|
||||
|
||||
static void fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column,
|
||||
WMList *list);
|
||||
WMList *list);
|
||||
|
||||
static void deleteFile();
|
||||
|
||||
@@ -89,10 +89,10 @@ static void handleEvents(XEvent *event, void *data);
|
||||
|
||||
static WMBrowserDelegate browserDelegate = {
|
||||
NULL, /* data */
|
||||
fillColumn, /* createRowsForColumn */
|
||||
NULL, /* titleOfColumn */
|
||||
NULL, /* didScroll */
|
||||
NULL /* willScroll */
|
||||
fillColumn, /* createRowsForColumn */
|
||||
NULL, /* titleOfColumn */
|
||||
NULL, /* didScroll */
|
||||
NULL /* willScroll */
|
||||
};
|
||||
|
||||
|
||||
@@ -104,15 +104,15 @@ closestListItem(WMList *list, char *text, Bool exact)
|
||||
int i, len = strlen(text);
|
||||
|
||||
if (len==0)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
for(i=0; i<WMGetArrayItemCount(items); i++) {
|
||||
item = WMGetFromArray(items, i);
|
||||
if (strlen(item->text) >= len &&
|
||||
((exact && strcmp(item->text, text)==0) ||
|
||||
(!exact && strncmp(item->text, text, len)==0))) {
|
||||
return i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -129,7 +129,7 @@ textChangedObserver(void *observerData, WMNotification *notification)
|
||||
int i, textEvent;
|
||||
|
||||
if (!(list = WMGetBrowserListInColumn(panel->browser, col)))
|
||||
return;
|
||||
return;
|
||||
|
||||
text = WMGetTextFieldText(panel->fileField);
|
||||
textEvent = (int)WMGetNotificationClientData(notification);
|
||||
@@ -144,19 +144,19 @@ textChangedObserver(void *observerData, WMNotification *notification)
|
||||
WMListItem *item = WMGetListItem(list, i);
|
||||
int textLen = strlen(text), itemTextLen = strlen(item->text);
|
||||
int visibleItems = WMWidgetHeight(list)/WMGetListItemHeight(list);
|
||||
|
||||
|
||||
WMSetListPosition(list, i - visibleItems/2);
|
||||
|
||||
|
||||
if (textEvent!=WMDeleteTextEvent) {
|
||||
WMRange range;
|
||||
|
||||
WMInsertTextFieldText(panel->fileField, &item->text[textLen],
|
||||
WMInsertTextFieldText(panel->fileField, &item->text[textLen],
|
||||
textLen);
|
||||
range.position = textLen;
|
||||
range.count = itemTextLen - textLen;
|
||||
WMSelectTextFieldRange(panel->fileField, range);
|
||||
range.position = textLen;
|
||||
range.count = itemTextLen - textLen;
|
||||
WMSelectTextFieldRange(panel->fileField, range);
|
||||
/*WMSetTextFieldCursorPosition(panel->fileField, itemTextLen);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wfree(text);
|
||||
@@ -169,7 +169,7 @@ textEditedObserver(void *observerData, WMNotification *notification)
|
||||
W_FilePanel *panel = (W_FilePanel*)observerData;
|
||||
|
||||
if ((int)WMGetNotificationClientData(notification)==WMReturnTextMovement) {
|
||||
WMPerformButtonClick(panel->okButton);
|
||||
WMPerformButtonClick(panel->okButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
memset(fPtr, 0, sizeof(WMFilePanel));
|
||||
|
||||
fPtr->win = WMCreateWindowWithStyle(scrPtr, name, WMTitledWindowMask
|
||||
|WMResizableWindowMask);
|
||||
|WMResizableWindowMask);
|
||||
WMResizeWidget(fPtr->win, PWIDTH, PHEIGHT);
|
||||
WMSetWindowTitle(fPtr->win, "");
|
||||
|
||||
@@ -206,7 +206,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
} else {
|
||||
WMSetLabelImage(fPtr->iconLabel, scrPtr->applicationIconPixmap);
|
||||
}
|
||||
|
||||
|
||||
fPtr->titleLabel = WMCreateLabel(fPtr->win);
|
||||
WMResizeWidget(fPtr->titleLabel, PWIDTH-64, 64);
|
||||
WMMoveWidget(fPtr->titleLabel, 64, 0);
|
||||
@@ -214,7 +214,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
WMSetLabelFont(fPtr->titleLabel, largeFont);
|
||||
WMReleaseFont(largeFont);
|
||||
WMSetLabelText(fPtr->titleLabel, title);
|
||||
|
||||
|
||||
fPtr->line = WMCreateFrame(fPtr->win);
|
||||
WMMoveWidget(fPtr->line, 0, 64);
|
||||
WMResizeWidget(fPtr->line, PWIDTH, 2);
|
||||
@@ -233,17 +233,17 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
WMMoveWidget(fPtr->nameLabel, 7, 282);
|
||||
WMResizeWidget(fPtr->nameLabel, 55, 14);
|
||||
WMSetLabelText(fPtr->nameLabel, _("Name:"));
|
||||
|
||||
|
||||
fPtr->fileField = WMCreateTextField(fPtr->win);
|
||||
WMMoveWidget(fPtr->fileField, 60, 278);
|
||||
WMResizeWidget(fPtr->fileField, PWIDTH-60-10, 24);
|
||||
WMAddNotificationObserver(textEditedObserver, fPtr,
|
||||
WMTextDidEndEditingNotification,
|
||||
fPtr->fileField);
|
||||
WMTextDidEndEditingNotification,
|
||||
fPtr->fileField);
|
||||
WMAddNotificationObserver(textChangedObserver, fPtr,
|
||||
WMTextDidChangeNotification,
|
||||
fPtr->fileField);
|
||||
|
||||
WMTextDidChangeNotification,
|
||||
fPtr->fileField);
|
||||
|
||||
fPtr->okButton = WMCreateCommandButton(fPtr->win);
|
||||
WMMoveWidget(fPtr->okButton, 245, 325);
|
||||
WMResizeWidget(fPtr->okButton, 75, 28);
|
||||
@@ -252,7 +252,7 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
WMSetButtonAltImage(fPtr->okButton, scrPtr->pushedButtonArrow);
|
||||
WMSetButtonImagePosition(fPtr->okButton, WIPRight);
|
||||
WMSetButtonAction(fPtr->okButton, buttonClick, fPtr);
|
||||
|
||||
|
||||
fPtr->cancelButton = WMCreateCommandButton(fPtr->win);
|
||||
WMMoveWidget(fPtr->cancelButton, 165, 325);
|
||||
WMResizeWidget(fPtr->cancelButton, 75, 28);
|
||||
@@ -308,10 +308,10 @@ makeFilePanel(WMScreen *scrPtr, char *name, char *title)
|
||||
WMSetTextFieldCursorPosition(fPtr->fileField, 0);
|
||||
|
||||
WMLoadBrowserColumnZero(fPtr->browser);
|
||||
|
||||
|
||||
WMSetWindowInitialPosition(fPtr->win,
|
||||
(scrPtr->rootView->size.width - WMWidgetWidth(fPtr->win))/2,
|
||||
(scrPtr->rootView->size.height - WMWidgetHeight(fPtr->win))/2);
|
||||
(scrPtr->rootView->size.width - WMWidgetWidth(fPtr->win))/2,
|
||||
(scrPtr->rootView->size.height - WMWidgetHeight(fPtr->win))/2);
|
||||
|
||||
fPtr->flags.canChooseFiles = 1;
|
||||
fPtr->flags.canChooseDirectories = 1;
|
||||
@@ -325,9 +325,9 @@ WMOpenPanel*
|
||||
WMGetOpenPanel(WMScreen *scrPtr)
|
||||
{
|
||||
WMFilePanel *panel;
|
||||
|
||||
|
||||
if (scrPtr->sharedOpenPanel)
|
||||
return scrPtr->sharedOpenPanel;
|
||||
return scrPtr->sharedOpenPanel;
|
||||
|
||||
panel = makeFilePanel(scrPtr, "openFilePanel", _("Open"));
|
||||
panel->flags.fileMustExist = 1;
|
||||
@@ -345,7 +345,7 @@ WMGetSavePanel(WMScreen *scrPtr)
|
||||
WMFilePanel *panel;
|
||||
|
||||
if (scrPtr->sharedSavePanel)
|
||||
return scrPtr->sharedSavePanel;
|
||||
return scrPtr->sharedSavePanel;
|
||||
|
||||
panel = makeFilePanel(scrPtr, "saveFilePanel", _("Save"));
|
||||
panel->flags.fileMustExist = 0;
|
||||
@@ -361,10 +361,10 @@ void
|
||||
WMFreeFilePanel(WMFilePanel *panel)
|
||||
{
|
||||
if (panel == WMWidgetScreen(panel->win)->sharedSavePanel) {
|
||||
WMWidgetScreen(panel->win)->sharedSavePanel = NULL;
|
||||
WMWidgetScreen(panel->win)->sharedSavePanel = NULL;
|
||||
}
|
||||
if (panel == WMWidgetScreen(panel->win)->sharedOpenPanel) {
|
||||
WMWidgetScreen(panel->win)->sharedOpenPanel = NULL;
|
||||
WMWidgetScreen(panel->win)->sharedOpenPanel = NULL;
|
||||
}
|
||||
WMRemoveNotificationObserver(panel);
|
||||
WMUnmapWidget(panel->win);
|
||||
@@ -412,7 +412,7 @@ WMRunModalFilePanelForDirectory(WMFilePanel *panel, WMWindow *owner,
|
||||
WMRunModalLoop(scr, W_VIEW(panel->win));
|
||||
|
||||
/* Must withdraw window because the next time we map
|
||||
* it, it might have a different transient owner.
|
||||
* it, it might have a different transient owner.
|
||||
*/
|
||||
WMCloseWindow(panel->win);
|
||||
|
||||
@@ -447,7 +447,7 @@ WMSetFilePanelDirectory(WMFilePanel *panel, char *path)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
WMSetFilePanelCanChooseDirectories(WMFilePanel *panel, Bool flag)
|
||||
{
|
||||
@@ -501,21 +501,21 @@ static char*
|
||||
get_name_from_path(char *path)
|
||||
{
|
||||
int size;
|
||||
|
||||
|
||||
assert(path!=NULL);
|
||||
|
||||
|
||||
size = strlen(path);
|
||||
|
||||
/* remove trailing / */
|
||||
while (size > 0 && path[size-1]=='/')
|
||||
size--;
|
||||
size--;
|
||||
/* directory was root */
|
||||
if (size == 0)
|
||||
return wstrdup("/");
|
||||
return wstrdup("/");
|
||||
|
||||
while (size > 0 && path[size-1] != '/')
|
||||
size--;
|
||||
|
||||
size--;
|
||||
|
||||
return wstrdup(&(path[size]));
|
||||
}
|
||||
|
||||
@@ -532,9 +532,9 @@ static int
|
||||
comparer(const void *a, const void *b)
|
||||
{
|
||||
if (CAST(a)->isBranch == CAST(b)->isBranch)
|
||||
return (strcmp(CAST(a)->text, CAST(b)->text));
|
||||
return (strcmp(CAST(a)->text, CAST(b)->text));
|
||||
if (CAST(a)->isBranch)
|
||||
return (-1);
|
||||
return (-1);
|
||||
return (1);
|
||||
}
|
||||
#undef CAST
|
||||
@@ -557,40 +557,40 @@ listDirectoryOnColumn(WMFilePanel *panel, int column, char *path)
|
||||
name = get_name_from_path(path);
|
||||
WMSetBrowserColumnTitle(bPtr, column, name);
|
||||
wfree(name);
|
||||
|
||||
|
||||
dir = opendir(path);
|
||||
|
||||
|
||||
if (!dir) {
|
||||
#ifdef VERBOSE
|
||||
printf(_("WINGs: could not open directory %s\n"), path);
|
||||
printf(_("WINGs: could not open directory %s\n"), path);
|
||||
#endif
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
/* list contents in the column */
|
||||
while ((dentry = readdir(dir))) {
|
||||
if (strcmp(dentry->d_name, ".")==0 ||
|
||||
strcmp(dentry->d_name, "..")==0)
|
||||
continue;
|
||||
while ((dentry = readdir(dir))) {
|
||||
if (strcmp(dentry->d_name, ".")==0 ||
|
||||
strcmp(dentry->d_name, "..")==0)
|
||||
continue;
|
||||
|
||||
strcpy(pbuf, path);
|
||||
if (strcmp(path, "/")!=0)
|
||||
strcat(pbuf, "/");
|
||||
strcat(pbuf, dentry->d_name);
|
||||
strcpy(pbuf, path);
|
||||
if (strcmp(path, "/")!=0)
|
||||
strcat(pbuf, "/");
|
||||
strcat(pbuf, dentry->d_name);
|
||||
|
||||
if (stat(pbuf, &stat_buf)!=0) {
|
||||
if (stat(pbuf, &stat_buf)!=0) {
|
||||
#ifdef VERBOSE
|
||||
printf(_("WINGs: could not stat %s\n"), pbuf);
|
||||
printf(_("WINGs: could not stat %s\n"), pbuf);
|
||||
#endif
|
||||
continue;
|
||||
} else {
|
||||
int isDirectory;
|
||||
continue;
|
||||
} else {
|
||||
int isDirectory;
|
||||
|
||||
isDirectory = S_ISDIR(stat_buf.st_mode);
|
||||
|
||||
if (filterFileName(panel, dentry->d_name, isDirectory))
|
||||
WMInsertBrowserItem(bPtr, column, -1, dentry->d_name, isDirectory);
|
||||
}
|
||||
isDirectory = S_ISDIR(stat_buf.st_mode);
|
||||
|
||||
if (filterFileName(panel, dentry->d_name, isDirectory))
|
||||
WMInsertBrowserItem(bPtr, column, -1, dentry->d_name, isDirectory);
|
||||
}
|
||||
}
|
||||
WMSortBrowserColumnWithComparer(bPtr, column, comparer);
|
||||
|
||||
@@ -603,11 +603,11 @@ fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column, WMList *list)
|
||||
{
|
||||
char *path;
|
||||
WMFilePanel *panel;
|
||||
|
||||
|
||||
if (column > 0) {
|
||||
path = WMGetBrowserPathToColumn(bPtr, column-1);
|
||||
path = WMGetBrowserPathToColumn(bPtr, column-1);
|
||||
} else {
|
||||
path = wstrdup("/");
|
||||
path = wstrdup("/");
|
||||
}
|
||||
|
||||
panel = WMGetHangedData(bPtr);
|
||||
@@ -616,22 +616,22 @@ fillColumn(WMBrowserDelegate *self, WMBrowser *bPtr, int column, WMList *list)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static void
|
||||
browserDClick(WMBrowser *bPtr, WMFilePanel *panel)
|
||||
{
|
||||
WMPerformButtonClick(panel->okButton);
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
browserClick(WMBrowser *bPtr, WMFilePanel *panel)
|
||||
{
|
||||
int col = WMGetBrowserSelectedColumn(bPtr);
|
||||
WMListItem *item = WMGetBrowserSelectedItemInColumn(bPtr, col);
|
||||
|
||||
if (!item || item->isBranch)
|
||||
WMSetTextFieldText(panel->fileField, NULL);
|
||||
WMSetTextFieldText(panel->fileField, NULL);
|
||||
else {
|
||||
WMSetTextFieldText(panel->fileField, item->text);
|
||||
WMSetTextFieldText(panel->fileField, item->text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,14 +694,14 @@ createDir(WMButton *bPre, WMFilePanel *panel)
|
||||
|
||||
if (mkdir(file,0xfff) != 0) {
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case EEXIST:
|
||||
showError(scr, panel->win, _("'%s' already exists."), file);
|
||||
break;
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("Path does not exist."), NULL);
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case EEXIST:
|
||||
showError(scr, panel->win, _("'%s' already exists."), file);
|
||||
break;
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("Path does not exist."), NULL);
|
||||
}
|
||||
}
|
||||
else WMSetFilePanelDirectory(panel, file);
|
||||
@@ -730,54 +730,54 @@ deleteFile(WMButton *bPre, WMFilePanel *panel)
|
||||
|
||||
if (stat(file,&filestat)) {
|
||||
switch (errno) {
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("'%s' does not exist."), file);
|
||||
break;
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case ENOMEM:
|
||||
showError(scr, panel->win,
|
||||
_("Insufficient memory available."), NULL);
|
||||
break;
|
||||
case EROFS:
|
||||
showError(scr, panel->win,
|
||||
_("'%s' is on a read-only filesystem."), file);
|
||||
break;
|
||||
default:
|
||||
showError(scr, panel->win, _("Can not delete '%s'."), file);
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("'%s' does not exist."), file);
|
||||
break;
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case ENOMEM:
|
||||
showError(scr, panel->win,
|
||||
_("Insufficient memory available."), NULL);
|
||||
break;
|
||||
case EROFS:
|
||||
showError(scr, panel->win,
|
||||
_("'%s' is on a read-only filesystem."), file);
|
||||
break;
|
||||
default:
|
||||
showError(scr, panel->win, _("Can not delete '%s'."), file);
|
||||
}
|
||||
wfree(file);
|
||||
return;
|
||||
} else if (S_ISDIR(filestat.st_mode)) {
|
||||
int len = strlen(file)+20;
|
||||
int len = strlen(file)+20;
|
||||
buffer = wmalloc(len);
|
||||
snprintf(buffer,len,_("Delete directory %s ?"),file);
|
||||
} else {
|
||||
int len = strlen(file)+15;
|
||||
int len = strlen(file)+15;
|
||||
buffer = wmalloc(len);
|
||||
snprintf(buffer,len,_("Delete file %s ?"),file);
|
||||
}
|
||||
|
||||
if (!WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
|
||||
_("Warning"), buffer, _("OK"), _("Cancel"), NULL)) {
|
||||
_("Warning"), buffer, _("OK"), _("Cancel"), NULL)) {
|
||||
if (S_ISDIR(filestat.st_mode)) {
|
||||
if (rmdir(file) != 0) {
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("Directory '%s' does not exist."), file);
|
||||
break;
|
||||
case ENOTEMPTY:
|
||||
showError(scr, panel->win, _("Directory '%s' is not empty."), file);
|
||||
break;
|
||||
case EBUSY:
|
||||
showError(scr, panel->win, _("Directory '%s' is busy."), file);
|
||||
break;
|
||||
default:
|
||||
showError(scr, panel->win, _("Can not delete '%s'."), file);
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("Directory '%s' does not exist."), file);
|
||||
break;
|
||||
case ENOTEMPTY:
|
||||
showError(scr, panel->win, _("Directory '%s' is not empty."), file);
|
||||
break;
|
||||
case EBUSY:
|
||||
showError(scr, panel->win, _("Directory '%s' is busy."), file);
|
||||
break;
|
||||
default:
|
||||
showError(scr, panel->win, _("Can not delete '%s'."), file);
|
||||
}
|
||||
} else {
|
||||
char *s = strrchr(file,'/');
|
||||
@@ -786,25 +786,25 @@ deleteFile(WMButton *bPre, WMFilePanel *panel)
|
||||
}
|
||||
} else if (remove(file) != 0) {
|
||||
switch (errno) {
|
||||
case EISDIR:
|
||||
showError(scr, panel->win, _("'%s' is a directory."), file);
|
||||
break;
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("'%s' does not exist."), file);
|
||||
break;
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case ENOMEM:
|
||||
showError(scr, panel->win,
|
||||
_("Insufficient memory available."), NULL);
|
||||
break;
|
||||
case EROFS:
|
||||
showError(scr, panel->win,
|
||||
_("'%s' is on a read-only filesystem."), file);
|
||||
break;
|
||||
default:
|
||||
showError(scr, panel->win, _("Can not delete '%s'."), file);
|
||||
case EISDIR:
|
||||
showError(scr, panel->win, _("'%s' is a directory."), file);
|
||||
break;
|
||||
case ENOENT:
|
||||
showError(scr, panel->win, _("'%s' does not exist."), file);
|
||||
break;
|
||||
case EACCES:
|
||||
showError(scr, panel->win, _("Permission denied."), NULL);
|
||||
break;
|
||||
case ENOMEM:
|
||||
showError(scr, panel->win,
|
||||
_("Insufficient memory available."), NULL);
|
||||
break;
|
||||
case EROFS:
|
||||
showError(scr, panel->win,
|
||||
_("'%s' is on a read-only filesystem."), file);
|
||||
break;
|
||||
default:
|
||||
showError(scr, panel->win, _("Can not delete '%s'."), file);
|
||||
}
|
||||
} else {
|
||||
char *s = strrchr(file,'/');
|
||||
@@ -837,7 +837,7 @@ goFloppy(WMButton *bPtr, WMFilePanel *panel)
|
||||
WINGsConfiguration.floppyPath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WMSetFilePanelDirectory(panel, WINGsConfiguration.floppyPath);
|
||||
}
|
||||
|
||||
@@ -850,13 +850,13 @@ goHome(WMButton *bPtr, WMFilePanel *panel)
|
||||
/* home is statically allocated. Don't free it! */
|
||||
home = wgethomedir();
|
||||
if (!home)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
WMSetFilePanelDirectory(panel, home);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static void
|
||||
handleEvents(XEvent *event, void *data)
|
||||
{
|
||||
W_FilePanel *pPtr = (W_FilePanel*)data;
|
||||
@@ -867,7 +867,7 @@ handleEvents(XEvent *event, void *data)
|
||||
|| event->xconfigure.height != view->size.height) {
|
||||
unsigned int newWidth = event->xconfigure.width;
|
||||
unsigned int newHeight = event->xconfigure.height;
|
||||
int newColumnCount;
|
||||
int newColumnCount;
|
||||
|
||||
W_ResizeView(view, newWidth, newHeight);
|
||||
WMResizeWidget(pPtr->line, newWidth, 2);
|
||||
@@ -877,9 +877,9 @@ handleEvents(XEvent *event, void *data)
|
||||
WMMoveWidget(pPtr->nameLabel, 7, newHeight-(PHEIGHT-282));
|
||||
WMMoveWidget(pPtr->fileField, 60, newHeight-(PHEIGHT-278));
|
||||
WMMoveWidget(pPtr->okButton, newWidth-(PWIDTH-245),
|
||||
newHeight-(PHEIGHT-325));
|
||||
newHeight-(PHEIGHT-325));
|
||||
WMMoveWidget(pPtr->cancelButton, newWidth-(PWIDTH-165),
|
||||
newHeight-(PHEIGHT-325));
|
||||
newHeight-(PHEIGHT-325));
|
||||
|
||||
WMMoveWidget(pPtr->trashcanButton, 7, newHeight-(PHEIGHT-325));
|
||||
WMMoveWidget(pPtr->createDirButton, 37, newHeight-(PHEIGHT-325));
|
||||
@@ -887,8 +887,8 @@ handleEvents(XEvent *event, void *data)
|
||||
WMMoveWidget(pPtr->disketteButton, 97, newHeight-(PHEIGHT-325));
|
||||
WMMoveWidget(pPtr->unmountButton, 127, newHeight-(PHEIGHT-325));
|
||||
|
||||
newColumnCount = (newWidth - 14) / 140;
|
||||
WMSetBrowserMaxVisibleColumns(pPtr->browser, newColumnCount);
|
||||
newColumnCount = (newWidth - 14) / 140;
|
||||
WMSetBrowserMaxVisibleColumns(pPtr->browser, newColumnCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -901,24 +901,24 @@ getCurrentFileName(WMFilePanel *panel)
|
||||
char *file;
|
||||
char *tmp;
|
||||
int len;
|
||||
|
||||
|
||||
path = WMGetBrowserPath(panel->browser);
|
||||
|
||||
|
||||
len = strlen(path);
|
||||
if (path[len-1]=='/') {
|
||||
file = WMGetTextFieldText(panel->fileField);
|
||||
tmp = wmalloc(strlen(path)+strlen(file)+8);
|
||||
file = WMGetTextFieldText(panel->fileField);
|
||||
tmp = wmalloc(strlen(path)+strlen(file)+8);
|
||||
if (file[0]!='/') {
|
||||
strcpy(tmp, path);
|
||||
strcat(tmp, file);
|
||||
strcpy(tmp, path);
|
||||
strcat(tmp, file);
|
||||
} else
|
||||
strcpy(tmp, file);
|
||||
strcpy(tmp, file);
|
||||
|
||||
wfree(file);
|
||||
wfree(path);
|
||||
return tmp;
|
||||
wfree(file);
|
||||
wfree(path);
|
||||
return tmp;
|
||||
} else {
|
||||
return path;
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -938,16 +938,16 @@ validOpenFile(WMFilePanel *panel)
|
||||
col = WMGetBrowserSelectedColumn(panel->browser);
|
||||
item = WMGetBrowserSelectedItemInColumn(panel->browser, col);
|
||||
if (item) {
|
||||
if (item->isBranch && !panel->flags.canChooseDirectories && !haveFile)
|
||||
return False;
|
||||
else if (!item->isBranch && !panel->flags.canChooseFiles)
|
||||
if (item->isBranch && !panel->flags.canChooseDirectories && !haveFile)
|
||||
return False;
|
||||
else if (!item->isBranch && !panel->flags.canChooseFiles)
|
||||
return False;
|
||||
else
|
||||
return True;
|
||||
} else {
|
||||
/* we compute for / here */
|
||||
if (!panel->flags.canChooseDirectories && !haveFile)
|
||||
return False;
|
||||
if (!panel->flags.canChooseDirectories && !haveFile)
|
||||
return False;
|
||||
else
|
||||
return True;
|
||||
}
|
||||
@@ -964,22 +964,22 @@ buttonClick(WMButton *bPtr, WMFilePanel *panel)
|
||||
if (bPtr == panel->okButton) {
|
||||
if (!validOpenFile(panel))
|
||||
return;
|
||||
if (panel->flags.fileMustExist) {
|
||||
char *file;
|
||||
|
||||
file = getCurrentFileName(panel);
|
||||
if (access(file, F_OK)!=0) {
|
||||
WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
|
||||
_("Error"), _("File does not exist."),
|
||||
_("OK"), NULL, NULL);
|
||||
wfree(file);
|
||||
return;
|
||||
}
|
||||
wfree(file);
|
||||
}
|
||||
panel->flags.canceled = 0;
|
||||
if (panel->flags.fileMustExist) {
|
||||
char *file;
|
||||
|
||||
file = getCurrentFileName(panel);
|
||||
if (access(file, F_OK)!=0) {
|
||||
WMRunAlertPanel(WMWidgetScreen(panel->win), panel->win,
|
||||
_("Error"), _("File does not exist."),
|
||||
_("OK"), NULL, NULL);
|
||||
wfree(file);
|
||||
return;
|
||||
}
|
||||
wfree(file);
|
||||
}
|
||||
panel->flags.canceled = 0;
|
||||
} else
|
||||
panel->flags.canceled = 1;
|
||||
panel->flags.canceled = 1;
|
||||
|
||||
range.count = range.position = 0;
|
||||
WMSelectTextFieldRange(panel->fileField, range);
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ WMCreateFontWithFlags(WMScreen *scrPtr, char *fontName, WMFontFlags flags)
|
||||
multiByte = False;
|
||||
}
|
||||
|
||||
} else if (multiByte) {
|
||||
if (multiByte) {
|
||||
font = WMCreateFontSet(scrPtr, fontName);
|
||||
} else {
|
||||
font = WMCreateNormalFont(scrPtr, fontName);
|
||||
|
||||
@@ -275,3 +275,4 @@ destroyFrame(Frame *fPtr)
|
||||
|
||||
wfree(fPtr);
|
||||
}
|
||||
|
||||
+185
-185
@@ -21,96 +21,96 @@
|
||||
#define CHECK_BUTTON_ON_HEIGHT 16
|
||||
|
||||
static char *CHECK_BUTTON_ON[] = {
|
||||
" %",
|
||||
" .............%#",
|
||||
" ........... .%#",
|
||||
" .......... #.%#",
|
||||
" ......... #%.%#",
|
||||
" ........ #%..%#",
|
||||
" ... #.. #%...%#",
|
||||
" ... #% #%....%#",
|
||||
" ... % #%.....%#",
|
||||
" ... #%......%#",
|
||||
" ... #%.......%#",
|
||||
" ...#%........%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" %%%%%%%%%%%%%%#",
|
||||
"%###############"};
|
||||
" %",
|
||||
" .............%#",
|
||||
" ........... .%#",
|
||||
" .......... #.%#",
|
||||
" ......... #%.%#",
|
||||
" ........ #%..%#",
|
||||
" ... #.. #%...%#",
|
||||
" ... #% #%....%#",
|
||||
" ... % #%.....%#",
|
||||
" ... #%......%#",
|
||||
" ... #%.......%#",
|
||||
" ...#%........%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" %%%%%%%%%%%%%%#",
|
||||
"%###############"};
|
||||
|
||||
#define CHECK_BUTTON_OFF_WIDTH 16
|
||||
#define CHECK_BUTTON_OFF_HEIGHT 16
|
||||
|
||||
static char *CHECK_BUTTON_OFF[] = {
|
||||
" %",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" %%%%%%%%%%%%%%#",
|
||||
"%###############"};
|
||||
" %",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" .............%#",
|
||||
" %%%%%%%%%%%%%%#",
|
||||
"%###############"};
|
||||
|
||||
#define RADIO_BUTTON_ON_WIDTH 15
|
||||
#define RADIO_BUTTON_ON_HEIGHT 15
|
||||
static char *RADIO_BUTTON_ON[] = {
|
||||
".....%%%%%.....",
|
||||
"...%%#####%%...",
|
||||
"..%##.....%.%..",
|
||||
".%#%.. .....",
|
||||
".%#. ...",
|
||||
"%#.. .. ",
|
||||
"%#. . ",
|
||||
"%#. . ",
|
||||
"%#. . ",
|
||||
"%#. . ",
|
||||
".%%. . .",
|
||||
".%.. . .",
|
||||
"..%... .. ..",
|
||||
".... ..... ...",
|
||||
"..... .....",
|
||||
".....%%%%%.....",
|
||||
"...%%#####%%...",
|
||||
"..%##.....%.%..",
|
||||
".%#%.. .....",
|
||||
".%#. ...",
|
||||
"%#.. .. ",
|
||||
"%#. . ",
|
||||
"%#. . ",
|
||||
"%#. . ",
|
||||
"%#. . ",
|
||||
".%%. . .",
|
||||
".%.. . .",
|
||||
"..%... .. ..",
|
||||
".... ..... ...",
|
||||
"..... .....",
|
||||
};
|
||||
|
||||
#define RADIO_BUTTON_OFF_WIDTH 15
|
||||
#define RADIO_BUTTON_OFF_HEIGHT 15
|
||||
static char *RADIO_BUTTON_OFF[] = {
|
||||
".....%%%%%.....",
|
||||
"...%%#####%%...",
|
||||
"..%##.......%..",
|
||||
".%#%...........",
|
||||
".%#............",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
".%%.......... .",
|
||||
".%........... .",
|
||||
"..%......... ..",
|
||||
".... ..... ...",
|
||||
"..... .....",
|
||||
".....%%%%%.....",
|
||||
"...%%#####%%...",
|
||||
"..%##.......%..",
|
||||
".%#%...........",
|
||||
".%#............",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
"%#............ ",
|
||||
".%%.......... .",
|
||||
".%........... .",
|
||||
"..%......... ..",
|
||||
".... ..... ...",
|
||||
"..... .....",
|
||||
};
|
||||
|
||||
|
||||
static char *BUTTON_ARROW[] = {
|
||||
"..................",
|
||||
"....##....#### ...",
|
||||
"...#.%....#... ...",
|
||||
"..#..%#####... ...",
|
||||
".#............ ...",
|
||||
"#............. ...",
|
||||
".#............ ...",
|
||||
"..#.. ...",
|
||||
"...#. ............",
|
||||
"....# ............"
|
||||
"..................",
|
||||
"....##....#### ...",
|
||||
"...#.%....#... ...",
|
||||
"..#..%#####... ...",
|
||||
".#............ ...",
|
||||
"#............. ...",
|
||||
".#............ ...",
|
||||
"..#.. ...",
|
||||
"...#. ............",
|
||||
"....# ............"
|
||||
};
|
||||
|
||||
#define BUTTON_ARROW_WIDTH 18
|
||||
@@ -118,16 +118,16 @@ static char *BUTTON_ARROW[] = {
|
||||
|
||||
|
||||
static char *BUTTON_ARROW2[] = {
|
||||
" ",
|
||||
" ## ####. ",
|
||||
" # % # . ",
|
||||
" # %##### . ",
|
||||
" # . ",
|
||||
"# . ",
|
||||
" # . ",
|
||||
" # .......... ",
|
||||
" # . ",
|
||||
" #. "
|
||||
" ",
|
||||
" ## ####. ",
|
||||
" # % # . ",
|
||||
" # %##### . ",
|
||||
" # . ",
|
||||
"# . ",
|
||||
" # . ",
|
||||
" # .......... ",
|
||||
" # . ",
|
||||
" #. "
|
||||
};
|
||||
|
||||
#define BUTTON_ARROW2_WIDTH 18
|
||||
@@ -135,12 +135,12 @@ static char *BUTTON_ARROW2[] = {
|
||||
|
||||
|
||||
static char *SCROLLER_DIMPLE[] = {
|
||||
".%###.",
|
||||
"%#%%%%",
|
||||
"#%%...",
|
||||
"#%.. ",
|
||||
"#%. ",
|
||||
".%. ."
|
||||
".%###.",
|
||||
"%#%%%%",
|
||||
"#%%...",
|
||||
"#%.. ",
|
||||
"#%. ",
|
||||
".%. ."
|
||||
};
|
||||
|
||||
#define SCROLLER_DIMPLE_WIDTH 6
|
||||
@@ -148,27 +148,27 @@ static char *SCROLLER_DIMPLE[] = {
|
||||
|
||||
|
||||
static char *SCROLLER_ARROW_UP[] = {
|
||||
"....%....",
|
||||
"....#....",
|
||||
"...%#%...",
|
||||
"...###...",
|
||||
"..%###%..",
|
||||
"..#####..",
|
||||
".%#####%.",
|
||||
".#######.",
|
||||
"%#######%"
|
||||
"....%....",
|
||||
"....#....",
|
||||
"...%#%...",
|
||||
"...###...",
|
||||
"..%###%..",
|
||||
"..#####..",
|
||||
".%#####%.",
|
||||
".#######.",
|
||||
"%#######%"
|
||||
};
|
||||
|
||||
static char *HI_SCROLLER_ARROW_UP[] = {
|
||||
" % ",
|
||||
" % ",
|
||||
" %%% ",
|
||||
" %%% ",
|
||||
" %%%%% ",
|
||||
" %%%%% ",
|
||||
" %%%%%%% ",
|
||||
" %%%%%%% ",
|
||||
"%%%%%%%%%"
|
||||
" % ",
|
||||
" % ",
|
||||
" %%% ",
|
||||
" %%% ",
|
||||
" %%%%% ",
|
||||
" %%%%% ",
|
||||
" %%%%%%% ",
|
||||
" %%%%%%% ",
|
||||
"%%%%%%%%%"
|
||||
};
|
||||
|
||||
#define SCROLLER_ARROW_UP_WIDTH 9
|
||||
@@ -176,27 +176,27 @@ static char *HI_SCROLLER_ARROW_UP[] = {
|
||||
|
||||
|
||||
static char *SCROLLER_ARROW_DOWN[] = {
|
||||
"%#######%",
|
||||
".#######.",
|
||||
".%#####%.",
|
||||
"..#####..",
|
||||
"..%###%..",
|
||||
"...###...",
|
||||
"...%#%...",
|
||||
"....#....",
|
||||
"....%...."
|
||||
"%#######%",
|
||||
".#######.",
|
||||
".%#####%.",
|
||||
"..#####..",
|
||||
"..%###%..",
|
||||
"...###...",
|
||||
"...%#%...",
|
||||
"....#....",
|
||||
"....%...."
|
||||
};
|
||||
|
||||
static char *HI_SCROLLER_ARROW_DOWN[] = {
|
||||
"%%%%%%%%%",
|
||||
" %%%%%%% ",
|
||||
" %%%%%%% ",
|
||||
" %%%%% ",
|
||||
" %%%%% ",
|
||||
" %%% ",
|
||||
" %%% ",
|
||||
" % ",
|
||||
" % "
|
||||
"%%%%%%%%%",
|
||||
" %%%%%%% ",
|
||||
" %%%%%%% ",
|
||||
" %%%%% ",
|
||||
" %%%%% ",
|
||||
" %%% ",
|
||||
" %%% ",
|
||||
" % ",
|
||||
" % "
|
||||
};
|
||||
|
||||
#define SCROLLER_ARROW_DOWN_WIDTH 9
|
||||
@@ -205,27 +205,27 @@ static char *HI_SCROLLER_ARROW_DOWN[] = {
|
||||
|
||||
|
||||
static char *SCROLLER_ARROW_LEFT[] = {
|
||||
"........%",
|
||||
"......%##",
|
||||
"....%####",
|
||||
"..%######",
|
||||
"%########",
|
||||
"..%######",
|
||||
"....%####",
|
||||
"......%##",
|
||||
"........%"
|
||||
"........%",
|
||||
"......%##",
|
||||
"....%####",
|
||||
"..%######",
|
||||
"%########",
|
||||
"..%######",
|
||||
"....%####",
|
||||
"......%##",
|
||||
"........%"
|
||||
};
|
||||
|
||||
static char *HI_SCROLLER_ARROW_LEFT[] = {
|
||||
" %",
|
||||
" %%%",
|
||||
" %%%%%",
|
||||
" %%%%%%%",
|
||||
"%%%%%%%%%",
|
||||
" %%%%%%%",
|
||||
" %%%%%",
|
||||
" %%%",
|
||||
" %"
|
||||
" %",
|
||||
" %%%",
|
||||
" %%%%%",
|
||||
" %%%%%%%",
|
||||
"%%%%%%%%%",
|
||||
" %%%%%%%",
|
||||
" %%%%%",
|
||||
" %%%",
|
||||
" %"
|
||||
};
|
||||
|
||||
#define SCROLLER_ARROW_LEFT_WIDTH 9
|
||||
@@ -233,27 +233,27 @@ static char *HI_SCROLLER_ARROW_LEFT[] = {
|
||||
|
||||
|
||||
static char *SCROLLER_ARROW_RIGHT[] = {
|
||||
"%........",
|
||||
"##%......",
|
||||
"####%....",
|
||||
"######%..",
|
||||
"########%",
|
||||
"######%..",
|
||||
"####%....",
|
||||
"##%......",
|
||||
"%........"
|
||||
"%........",
|
||||
"##%......",
|
||||
"####%....",
|
||||
"######%..",
|
||||
"########%",
|
||||
"######%..",
|
||||
"####%....",
|
||||
"##%......",
|
||||
"%........"
|
||||
};
|
||||
|
||||
static char *HI_SCROLLER_ARROW_RIGHT[] = {
|
||||
"% ",
|
||||
"%%% ",
|
||||
"%%%%% ",
|
||||
"%%%%%%% ",
|
||||
"%%%%%%%%%",
|
||||
"%%%%%%% ",
|
||||
"%%%%% ",
|
||||
"%%% ",
|
||||
"% "
|
||||
"% ",
|
||||
"%%% ",
|
||||
"%%%%% ",
|
||||
"%%%%%%% ",
|
||||
"%%%%%%%%%",
|
||||
"%%%%%%% ",
|
||||
"%%%%% ",
|
||||
"%%% ",
|
||||
"% "
|
||||
};
|
||||
|
||||
#define SCROLLER_ARROW_RIGHT_WIDTH 9
|
||||
@@ -261,14 +261,14 @@ static char *HI_SCROLLER_ARROW_RIGHT[] = {
|
||||
|
||||
|
||||
static char *POPUP_INDICATOR[] = {
|
||||
" #==",
|
||||
" ......%#==",
|
||||
" ......%#%%",
|
||||
" ......%#%%",
|
||||
" %%%%%%%#%%",
|
||||
"#########%%",
|
||||
"==%%%%%%%%%",
|
||||
"==%%%%%%%%%"
|
||||
" #==",
|
||||
" ......%#==",
|
||||
" ......%#%%",
|
||||
" ......%#%%",
|
||||
" %%%%%%%#%%",
|
||||
"#########%%",
|
||||
"==%%%%%%%%%",
|
||||
"==%%%%%%%%%"
|
||||
};
|
||||
|
||||
#define POPUP_INDICATOR_WIDTH 11
|
||||
@@ -277,13 +277,13 @@ static char *POPUP_INDICATOR[] = {
|
||||
|
||||
|
||||
static char *PULLDOWN_INDICATOR[] = {
|
||||
"=#######=",
|
||||
"=%===== =",
|
||||
"==%=== ==",
|
||||
"==%=== ==",
|
||||
"===%= ===",
|
||||
"===%= ===",
|
||||
"====%===="
|
||||
"=#######=",
|
||||
"=%===== =",
|
||||
"==%=== ==",
|
||||
"==%=== ==",
|
||||
"===%= ===",
|
||||
"===%= ===",
|
||||
"====%===="
|
||||
};
|
||||
#define PULLDOWN_INDICATOR_WIDTH 9
|
||||
#define PULLDOWN_INDICATOR_HEIGHT 7
|
||||
@@ -293,16 +293,16 @@ static char *PULLDOWN_INDICATOR[] = {
|
||||
#define CHECK_MARK_HEIGHT 10
|
||||
|
||||
static char *CHECK_MARK[] = {
|
||||
"======== ",
|
||||
"======= #",
|
||||
"====== #%",
|
||||
"===== #%=",
|
||||
" #== #%==",
|
||||
" #% #%===",
|
||||
" % #%====",
|
||||
" #%=====",
|
||||
" #%======",
|
||||
"#%======="};
|
||||
"======== ",
|
||||
"======= #",
|
||||
"====== #%",
|
||||
"===== #%=",
|
||||
" #== #%==",
|
||||
" #% #%===",
|
||||
" % #%====",
|
||||
" #%=====",
|
||||
" #%======",
|
||||
"#%======="};
|
||||
|
||||
|
||||
#define STIPPLE_WIDTH 8
|
||||
|
||||
+16
-16
@@ -8,7 +8,7 @@
|
||||
|
||||
typedef struct W_IMContext {
|
||||
XIM xim;
|
||||
|
||||
|
||||
struct W_ICContext *icList;
|
||||
} WMIMContext;
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef struct W_ICContext {
|
||||
struct W_ICContext *next;
|
||||
struct W_ICContext *prev;
|
||||
|
||||
XIC xic;
|
||||
XIC xic;
|
||||
} WMICContext;
|
||||
|
||||
|
||||
@@ -26,27 +26,27 @@ Bool
|
||||
W_InitIMStuff(WMScreen *scr)
|
||||
{
|
||||
WMIMContext *ctx;
|
||||
|
||||
|
||||
ctx = scr->imctx = wmalloc(sizeof(WMIMContext));
|
||||
|
||||
|
||||
ctx->xim = XOpenIM(scr->display, NULL, NULL, NULL);
|
||||
if (ctx->xim == NULL) {
|
||||
wwarning("could not open IM");
|
||||
return False;
|
||||
wwarning("could not open IM");
|
||||
return False;
|
||||
}
|
||||
|
||||
// XGetIMValues(scr->display,
|
||||
|
||||
//XGetIMValues(scr->display,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
W_CloseIMStuff(WMScreen *scr)
|
||||
{
|
||||
if (!scr->imctx)
|
||||
return;
|
||||
if (!scr->imctx)
|
||||
return;
|
||||
|
||||
if (scr->imctx->xim)
|
||||
XCloseIM(scr->imctx->xim);
|
||||
XCloseIM(scr->imctx->xim);
|
||||
wfree(scr->imctx);
|
||||
scr->imctx = NULL;
|
||||
}
|
||||
@@ -58,11 +58,11 @@ W_CreateIC(WMView *view)
|
||||
{
|
||||
WMScreen *scr = W_VIEW_SCREEN(view);
|
||||
WMICContext *ctx;
|
||||
|
||||
|
||||
ctx->prev = NULL;
|
||||
ctx->next = scr->imctx->icList;
|
||||
if (scr->imctx->icList)
|
||||
scr->imctx->icList->prev = ctx;
|
||||
scr->imctx->icList->prev = ctx;
|
||||
//scr->imctx = ctx;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ void
|
||||
W_DestroyIC(WMICContext *ctx)
|
||||
{
|
||||
XDestroyIC(ctx->xic);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ int
|
||||
W_LookupString(WMView *view, XKeyEvent *event,
|
||||
char buffer, int bufsize, KeySym ksym)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
+60
-58
@@ -9,22 +9,22 @@
|
||||
typedef struct W_Label {
|
||||
W_Class widgetClass;
|
||||
W_View *view;
|
||||
|
||||
|
||||
char *caption;
|
||||
|
||||
WMColor *textColor;
|
||||
WMFont *font; /* if NULL, use default */
|
||||
|
||||
|
||||
W_Pixmap *image;
|
||||
|
||||
struct {
|
||||
WMReliefType relief:3;
|
||||
WMImagePosition imagePosition:4;
|
||||
WMAlignment alignment:2;
|
||||
|
||||
unsigned int noWrap:1;
|
||||
WMReliefType relief:3;
|
||||
WMImagePosition imagePosition:4;
|
||||
WMAlignment alignment:2;
|
||||
|
||||
unsigned int redrawPending:1;
|
||||
unsigned int noWrap:1;
|
||||
|
||||
unsigned int redrawPending:1;
|
||||
} flags;
|
||||
} Label;
|
||||
|
||||
@@ -47,23 +47,23 @@ WMLabel*
|
||||
WMCreateLabel(WMWidget *parent)
|
||||
{
|
||||
Label *lPtr;
|
||||
|
||||
|
||||
lPtr = wmalloc(sizeof(Label));
|
||||
memset(lPtr, 0, sizeof(Label));
|
||||
|
||||
lPtr->widgetClass = WC_Label;
|
||||
|
||||
|
||||
lPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!lPtr->view) {
|
||||
wfree(lPtr);
|
||||
return NULL;
|
||||
wfree(lPtr);
|
||||
return NULL;
|
||||
}
|
||||
lPtr->view->self = lPtr;
|
||||
|
||||
|
||||
lPtr->textColor = WMRetainColor(lPtr->view->screen->black);
|
||||
|
||||
|
||||
WMCreateEventHandler(lPtr->view, ExposureMask|StructureNotifyMask,
|
||||
handleEvents, lPtr);
|
||||
handleEvents, lPtr);
|
||||
|
||||
W_ResizeView(lPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
lPtr->flags.alignment = DEFAULT_ALIGNMENT;
|
||||
@@ -78,16 +78,16 @@ WMCreateLabel(WMWidget *parent)
|
||||
void
|
||||
WMSetLabelImage(WMLabel *lPtr, WMPixmap *image)
|
||||
{
|
||||
if (lPtr->image!=NULL)
|
||||
WMReleasePixmap(lPtr->image);
|
||||
|
||||
if (lPtr->image!=NULL)
|
||||
WMReleasePixmap(lPtr->image);
|
||||
|
||||
if (image)
|
||||
lPtr->image = WMRetainPixmap(image);
|
||||
lPtr->image = WMRetainPixmap(image);
|
||||
else
|
||||
lPtr->image = NULL;
|
||||
lPtr->image = NULL;
|
||||
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,17 +111,17 @@ WMSetLabelImagePosition(WMLabel *lPtr, WMImagePosition position)
|
||||
{
|
||||
lPtr->flags.imagePosition = position;
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
WMSetLabelTextAlignment(WMLabel *lPtr, WMAlignment alignment)
|
||||
{
|
||||
lPtr->flags.alignment = alignment;
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ WMSetLabelRelief(WMLabel *lPtr, WMReliefType relief)
|
||||
{
|
||||
lPtr->flags.relief = relief;
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,15 +140,15 @@ void
|
||||
WMSetLabelText(WMLabel *lPtr, char *text)
|
||||
{
|
||||
if (lPtr->caption)
|
||||
wfree(lPtr->caption);
|
||||
|
||||
wfree(lPtr->caption);
|
||||
|
||||
if (text!=NULL) {
|
||||
lPtr->caption = wstrdup(text);
|
||||
lPtr->caption = wstrdup(text);
|
||||
} else {
|
||||
lPtr->caption = NULL;
|
||||
lPtr->caption = NULL;
|
||||
}
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,16 +162,16 @@ WMGetLabelFont(WMLabel *lPtr)
|
||||
|
||||
void
|
||||
WMSetLabelFont(WMLabel *lPtr, WMFont *font)
|
||||
{
|
||||
{
|
||||
if (lPtr->font!=NULL)
|
||||
WMReleaseFont(lPtr->font);
|
||||
WMReleaseFont(lPtr->font);
|
||||
if (font)
|
||||
lPtr->font = WMRetainFont(font);
|
||||
lPtr->font = WMRetainFont(font);
|
||||
else
|
||||
lPtr->font = NULL;
|
||||
lPtr->font = NULL;
|
||||
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,11 +180,11 @@ void
|
||||
WMSetLabelTextColor(WMLabel *lPtr, WMColor *color)
|
||||
{
|
||||
if (lPtr->textColor)
|
||||
WMReleaseColor(lPtr->textColor);
|
||||
WMReleaseColor(lPtr->textColor);
|
||||
lPtr->textColor = WMRetainColor(color);
|
||||
|
||||
if (lPtr->view->flags.realized) {
|
||||
paintLabel(lPtr);
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,9 +194,9 @@ WMSetLabelWraps(WMLabel *lPtr, Bool flag)
|
||||
{
|
||||
flag = ((flag==0) ? 0 : 1);
|
||||
if (lPtr->flags.noWrap != !flag) {
|
||||
lPtr->flags.noWrap = !flag;
|
||||
if (lPtr->view->flags.realized)
|
||||
paintLabel(lPtr);
|
||||
lPtr->flags.noWrap = !flag;
|
||||
if (lPtr->view->flags.realized)
|
||||
paintLabel(lPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,10 +208,10 @@ paintLabel(Label *lPtr)
|
||||
|
||||
W_PaintTextAndImage(lPtr->view, !lPtr->flags.noWrap,
|
||||
lPtr->textColor ? lPtr->textColor : scrPtr->black,
|
||||
(lPtr->font!=NULL ? lPtr->font : scrPtr->normalFont),
|
||||
lPtr->flags.relief, lPtr->caption,
|
||||
lPtr->flags.alignment, lPtr->image,
|
||||
lPtr->flags.imagePosition, NULL, 0);
|
||||
(lPtr->font!=NULL ? lPtr->font : scrPtr->normalFont),
|
||||
lPtr->flags.relief, lPtr->caption,
|
||||
lPtr->flags.alignment, lPtr->image,
|
||||
lPtr->flags.imagePosition, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,15 +225,15 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintLabel(lPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyLabel(lPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintLabel(lPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyLabel(lPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,16 +242,18 @@ static void
|
||||
destroyLabel(Label *lPtr)
|
||||
{
|
||||
if (lPtr->textColor)
|
||||
WMReleaseColor(lPtr->textColor);
|
||||
|
||||
WMReleaseColor(lPtr->textColor);
|
||||
|
||||
if (lPtr->caption)
|
||||
wfree(lPtr->caption);
|
||||
wfree(lPtr->caption);
|
||||
|
||||
if (lPtr->font)
|
||||
WMReleaseFont(lPtr->font);
|
||||
WMReleaseFont(lPtr->font);
|
||||
|
||||
if (lPtr->image)
|
||||
WMReleasePixmap(lPtr->image);
|
||||
WMReleasePixmap(lPtr->image);
|
||||
|
||||
wfree(lPtr);
|
||||
}
|
||||
|
||||
|
||||
+28
-28
@@ -20,14 +20,14 @@ typedef struct W_MenuItem {
|
||||
struct W_Menu *submenu;
|
||||
|
||||
void *object;
|
||||
|
||||
|
||||
WMPixmap *onStateImage;
|
||||
WMPixmap *offStateImage;
|
||||
WMPixmap *mixedStateImage;
|
||||
|
||||
struct {
|
||||
unsigned enabled:1;
|
||||
unsigned state:2;
|
||||
unsigned enabled:1;
|
||||
unsigned state:2;
|
||||
} flags;
|
||||
} MenuItem;
|
||||
|
||||
@@ -53,12 +53,12 @@ WMMenuItem*
|
||||
WMCreateMenuItem(void)
|
||||
{
|
||||
WMMenuItem *item;
|
||||
|
||||
|
||||
item = wmalloc(sizeof(WMMenuItem));
|
||||
memset(item, 0, sizeof(WMMenuItem));
|
||||
|
||||
item->flags.enabled = 1;
|
||||
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -67,22 +67,22 @@ void
|
||||
WMDestroyMenuItem(WMMenuItem *item)
|
||||
{
|
||||
if (item->title)
|
||||
wfree(item->title);
|
||||
wfree(item->title);
|
||||
|
||||
if (item->image)
|
||||
WMReleasePixmap(item->image);
|
||||
WMReleasePixmap(item->image);
|
||||
|
||||
if (item->shortcutKey)
|
||||
wfree(item->shortcutKey);
|
||||
|
||||
wfree(item->shortcutKey);
|
||||
|
||||
if (item->onStateImage)
|
||||
WMReleasePixmap(item->onStateImage);
|
||||
|
||||
WMReleasePixmap(item->onStateImage);
|
||||
|
||||
if (item->offStateImage)
|
||||
WMReleasePixmap(item->offStateImage);
|
||||
|
||||
WMReleasePixmap(item->offStateImage);
|
||||
|
||||
if (item->mixedStateImage)
|
||||
WMReleasePixmap(item->mixedStateImage);
|
||||
WMReleasePixmap(item->mixedStateImage);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void
|
||||
WMSetMenuItemShortcut(WMMenuItem *item, char *shortcut)
|
||||
{
|
||||
if (item->shortcutKey)
|
||||
wfree(item->shortcutKey);
|
||||
wfree(item->shortcutKey);
|
||||
|
||||
item->shortcutKey = wstrdup(shortcut);
|
||||
}
|
||||
@@ -172,12 +172,12 @@ void
|
||||
WMSetMenuItemTitle(WMMenuItem *item, char *title)
|
||||
{
|
||||
if (item->title)
|
||||
wfree(item->title);
|
||||
|
||||
wfree(item->title);
|
||||
|
||||
if (title)
|
||||
item->title = wstrdup(title);
|
||||
item->title = wstrdup(title);
|
||||
else
|
||||
item->title = NULL;
|
||||
item->title = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ void
|
||||
WMSetMenuItemPixmap(WMMenuItem *item, WMPixmap *pixmap)
|
||||
{
|
||||
if (item->image)
|
||||
WMReleasePixmap(item->image);
|
||||
WMReleasePixmap(item->image);
|
||||
|
||||
item->image = WMRetainPixmap(pixmap);
|
||||
}
|
||||
@@ -223,8 +223,8 @@ void
|
||||
WMSetMenuItemOnStatePixmap(WMMenuItem *item, WMPixmap *pixmap)
|
||||
{
|
||||
if (item->onStateImage)
|
||||
WMReleasePixmap(item->onStateImage);
|
||||
|
||||
WMReleasePixmap(item->onStateImage);
|
||||
|
||||
item->onStateImage = WMRetainPixmap(pixmap);
|
||||
}
|
||||
|
||||
@@ -240,8 +240,8 @@ void
|
||||
WMSetMenuItemOffStatePixmap(WMMenuItem *item, WMPixmap *pixmap)
|
||||
{
|
||||
if (item->offStateImage)
|
||||
WMReleasePixmap(item->offStateImage);
|
||||
|
||||
WMReleasePixmap(item->offStateImage);
|
||||
|
||||
item->offStateImage = WMRetainPixmap(pixmap);
|
||||
}
|
||||
|
||||
@@ -258,8 +258,8 @@ void
|
||||
WMSetMenuItemMixedStatePixmap(WMMenuItem *item, WMPixmap *pixmap)
|
||||
{
|
||||
if (item->mixedStateImage)
|
||||
WMReleasePixmap(item->mixedStateImage);
|
||||
|
||||
WMReleasePixmap(item->mixedStateImage);
|
||||
|
||||
item->mixedStateImage = WMRetainPixmap(pixmap);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ WMGetMenuItemMixedStatePixmap(WMMenuItem *item)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#if 0
|
||||
void
|
||||
WMSetMenuItemSubmenu(WMMenuItem *item, WMMenu *submenu)
|
||||
{
|
||||
@@ -292,5 +292,5 @@ WMGetMenuItemHasSubmenu(WMMenuItem *item)
|
||||
{
|
||||
return item->submenu != NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
*/
|
||||
+144
-144
@@ -7,18 +7,18 @@
|
||||
|
||||
void
|
||||
W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
unsigned int height, WMReliefType relief)
|
||||
unsigned int height, WMReliefType relief)
|
||||
{
|
||||
W_DrawReliefWithGC(scr, d, x, y, width, height, relief,
|
||||
WMColorGC(scr->black), WMColorGC(scr->darkGray),
|
||||
WMColorGC(scr->gray), WMColorGC(scr->white));
|
||||
WMColorGC(scr->black), WMColorGC(scr->darkGray),
|
||||
WMColorGC(scr->gray), WMColorGC(scr->white));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
unsigned int height, WMReliefType relief,
|
||||
GC black, GC dark, GC light, GC white)
|
||||
unsigned int height, WMReliefType relief,
|
||||
GC black, GC dark, GC light, GC white)
|
||||
{
|
||||
Display *dpy = scr->display;
|
||||
GC bgc;
|
||||
@@ -27,62 +27,62 @@ W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
GC dgc;
|
||||
|
||||
switch (relief) {
|
||||
case WRSimple:
|
||||
XDrawRectangle(dpy, d, black, x, y, width-1, height-1);
|
||||
return;
|
||||
case WRSimple:
|
||||
XDrawRectangle(dpy, d, black, x, y, width-1, height-1);
|
||||
return;
|
||||
|
||||
case WRRaised:
|
||||
bgc = black;
|
||||
dgc = dark;
|
||||
wgc = white;
|
||||
lgc = light;
|
||||
break;
|
||||
case WRRaised:
|
||||
bgc = black;
|
||||
dgc = dark;
|
||||
wgc = white;
|
||||
lgc = light;
|
||||
break;
|
||||
|
||||
case WRSunken:
|
||||
wgc = dark;
|
||||
lgc = black;
|
||||
bgc = white;
|
||||
dgc = light;
|
||||
break;
|
||||
case WRSunken:
|
||||
wgc = dark;
|
||||
lgc = black;
|
||||
bgc = white;
|
||||
dgc = light;
|
||||
break;
|
||||
|
||||
case WRPushed:
|
||||
lgc = wgc = black;
|
||||
dgc = bgc = white;
|
||||
break;
|
||||
case WRPushed:
|
||||
lgc = wgc = black;
|
||||
dgc = bgc = white;
|
||||
break;
|
||||
|
||||
case WRRidge:
|
||||
lgc = bgc = dark;
|
||||
dgc = wgc = white;
|
||||
break;
|
||||
case WRRidge:
|
||||
lgc = bgc = dark;
|
||||
dgc = wgc = white;
|
||||
break;
|
||||
|
||||
case WRGroove:
|
||||
wgc = dgc = dark;
|
||||
lgc = bgc = white;
|
||||
break;
|
||||
case WRGroove:
|
||||
wgc = dgc = dark;
|
||||
lgc = bgc = white;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
/* top left */
|
||||
XDrawLine(dpy, d, wgc, x, y, x+width-1, y);
|
||||
if (width > 2 && relief != WRRaised && relief!=WRPushed) {
|
||||
XDrawLine(dpy, d, lgc, x+1, y+1, x+width-3, y+1);
|
||||
XDrawLine(dpy, d, lgc, x+1, y+1, x+width-3, y+1);
|
||||
}
|
||||
|
||||
XDrawLine(dpy, d, wgc, x, y, x, y+height-1);
|
||||
if (height > 2 && relief != WRRaised && relief!=WRPushed) {
|
||||
XDrawLine(dpy, d, lgc, x+1, y+1, x+1, y+height-3);
|
||||
XDrawLine(dpy, d, lgc, x+1, y+1, x+1, y+height-3);
|
||||
}
|
||||
|
||||
/* bottom right */
|
||||
XDrawLine(dpy, d, bgc, x, y+height-1, x+width-1, y+height-1);
|
||||
if (width > 2 && relief!=WRPushed) {
|
||||
XDrawLine(dpy, d, dgc, x+1, y+height-2, x+width-2, y+height-2);
|
||||
XDrawLine(dpy, d, dgc, x+1, y+height-2, x+width-2, y+height-2);
|
||||
}
|
||||
|
||||
XDrawLine(dpy, d, bgc, x+width-1, y, x+width-1, y+height-1);
|
||||
if (height > 2 && relief!=WRPushed) {
|
||||
XDrawLine(dpy, d, dgc, x+width-2, y+1, x+width-2, y+height-2);
|
||||
XDrawLine(dpy, d, dgc, x+width-2, y+1, x+width-2, y+height-2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,29 +156,29 @@ fitText(char *text, WMFont *font, int width, int wrap)
|
||||
int w;
|
||||
|
||||
if (text[0]==0)
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
i = 0;
|
||||
if (wrap) {
|
||||
if (text[0]=='\n')
|
||||
return 0;
|
||||
if (text[0]=='\n')
|
||||
return 0;
|
||||
|
||||
do {
|
||||
i++;
|
||||
w = WMWidthOfString(font, text, i);
|
||||
} while (w < width && text[i]!='\n' && text[i]!=0);
|
||||
do {
|
||||
i++;
|
||||
w = WMWidthOfString(font, text, i);
|
||||
} while (w < width && text[i]!='\n' && text[i]!=0);
|
||||
|
||||
if (text[i]=='\n')
|
||||
return i;
|
||||
if (text[i]=='\n')
|
||||
return i;
|
||||
|
||||
/* keep words complete */
|
||||
if (!isspace(text[i])) {
|
||||
j = i;
|
||||
while (j>1 && !isspace(text[j]) && text[j]!=0)
|
||||
j--;
|
||||
if (j>1)
|
||||
i = j;
|
||||
}
|
||||
/* keep words complete */
|
||||
if (!isspace(text[i])) {
|
||||
j = i;
|
||||
while (j>1 && !isspace(text[j]) && text[j]!=0)
|
||||
j--;
|
||||
if (j>1)
|
||||
i = j;
|
||||
}
|
||||
} else {
|
||||
i = strcspn(text, "\n\r");
|
||||
}
|
||||
@@ -198,15 +198,15 @@ W_GetTextHeight(WMFont *font, char *text, int width, int wrap)
|
||||
|
||||
h = 0;
|
||||
while (length > 0) {
|
||||
count = fitText(ptr, font, width, wrap);
|
||||
count = fitText(ptr, font, width, wrap);
|
||||
|
||||
h += fheight;
|
||||
h += fheight;
|
||||
|
||||
if (isspace(ptr[count]))
|
||||
count++;
|
||||
if (isspace(ptr[count]))
|
||||
count++;
|
||||
|
||||
ptr += count;
|
||||
length -= count;
|
||||
ptr += count;
|
||||
length -= count;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
@@ -214,8 +214,8 @@ W_GetTextHeight(WMFont *font, char *text, int width, int wrap)
|
||||
|
||||
void
|
||||
W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
|
||||
int width, WMAlignment alignment, WMColor *color,
|
||||
int wrap, char *text, int length)
|
||||
int width, WMAlignment alignment, WMColor *color,
|
||||
int wrap, char *text, int length)
|
||||
{
|
||||
char *ptr = text;
|
||||
int line_width;
|
||||
@@ -224,17 +224,17 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
|
||||
int fheight = WMFontHeight(font);
|
||||
|
||||
while (length > 0) {
|
||||
count = fitText(ptr, font, width, wrap);
|
||||
count = fitText(ptr, font, width, wrap);
|
||||
|
||||
line_width = WMWidthOfString(font, ptr, count);
|
||||
if (alignment==WALeft)
|
||||
line_x = x;
|
||||
else if (alignment==WARight)
|
||||
line_x = x + width - line_width;
|
||||
else
|
||||
line_x = x + (width - line_width) / 2;
|
||||
line_width = WMWidthOfString(font, ptr, count);
|
||||
if (alignment==WALeft)
|
||||
line_x = x;
|
||||
else if (alignment==WARight)
|
||||
line_x = x + width - line_width;
|
||||
else
|
||||
line_x = x + (width - line_width) / 2;
|
||||
|
||||
WMDrawString(view->screen, d, color, font, line_x, y, ptr, count);
|
||||
WMDrawString(view->screen, d, color, font, line_x, y, ptr, count);
|
||||
|
||||
if (wrap && ptr[count]!='\n')
|
||||
y += fheight;
|
||||
@@ -244,17 +244,17 @@ W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
|
||||
count++;
|
||||
}
|
||||
|
||||
ptr += count;
|
||||
length -= count;
|
||||
ptr += count;
|
||||
length -= count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
|
||||
WMReliefType relief, char *text,
|
||||
WMAlignment alignment, W_Pixmap *image,
|
||||
WMImagePosition position, WMColor *backColor, int ofs)
|
||||
WMReliefType relief, char *text,
|
||||
WMAlignment alignment, W_Pixmap *image,
|
||||
WMImagePosition position, WMColor *backColor, int ofs)
|
||||
{
|
||||
W_Screen *screen = view->screen;
|
||||
int ix, iy;
|
||||
@@ -264,101 +264,101 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
|
||||
|
||||
#ifdef DOUBLE_BUFFER
|
||||
d = XCreatePixmap(screen->display, view->window,
|
||||
view->size.width, view->size.height, screen->depth);
|
||||
view->size.width, view->size.height, screen->depth);
|
||||
#endif
|
||||
|
||||
/* background */
|
||||
if (backColor) {
|
||||
XFillRectangle(screen->display, d, WMColorGC(backColor),
|
||||
0, 0, view->size.width, view->size.height);
|
||||
XFillRectangle(screen->display, d, WMColorGC(backColor),
|
||||
0, 0, view->size.width, view->size.height);
|
||||
} else {
|
||||
#ifndef DOUBLE_BUFFER
|
||||
XClearWindow(screen->display, d);
|
||||
XClearWindow(screen->display, d);
|
||||
#else
|
||||
XSetForeground(screen->display, screen->copyGC,
|
||||
view->attribs.background_pixel);
|
||||
XFillRectangle(screen->display, d, screen->copyGC, 0, 0,
|
||||
view->size.width, view->size.height);
|
||||
XSetForeground(screen->display, screen->copyGC,
|
||||
view->attribs.background_pixel);
|
||||
XFillRectangle(screen->display, d, screen->copyGC, 0, 0,
|
||||
view->size.width, view->size.height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
if (relief == WRFlat) {
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = view->size.width;
|
||||
h = view->size.height;
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = view->size.width;
|
||||
h = view->size.height;
|
||||
} else {
|
||||
x = 1;
|
||||
y = 1;
|
||||
w = view->size.width - 3;
|
||||
h = view->size.height - 3;
|
||||
x = 1;
|
||||
y = 1;
|
||||
w = view->size.width - 3;
|
||||
h = view->size.height - 3;
|
||||
}
|
||||
|
||||
/* calc. image alignment */
|
||||
if (position!=WIPNoImage && image!=NULL) {
|
||||
switch (position) {
|
||||
case WIPOverlaps:
|
||||
case WIPImageOnly:
|
||||
ix = (view->size.width - image->width) / 2;
|
||||
iy = (view->size.height - image->height) / 2;
|
||||
/*
|
||||
x = 2;
|
||||
y = 0;
|
||||
*/
|
||||
break;
|
||||
switch (position) {
|
||||
case WIPOverlaps:
|
||||
case WIPImageOnly:
|
||||
ix = (view->size.width - image->width) / 2;
|
||||
iy = (view->size.height - image->height) / 2;
|
||||
/*
|
||||
x = 2;
|
||||
y = 0;
|
||||
*/
|
||||
break;
|
||||
|
||||
case WIPLeft:
|
||||
ix = x;
|
||||
iy = y + (h - image->height) / 2;
|
||||
x = x + image->width + 5;
|
||||
y = 0;
|
||||
w -= image->width + 5;
|
||||
break;
|
||||
case WIPLeft:
|
||||
ix = x;
|
||||
iy = y + (h - image->height) / 2;
|
||||
x = x + image->width + 5;
|
||||
y = 0;
|
||||
w -= image->width + 5;
|
||||
break;
|
||||
|
||||
case WIPRight:
|
||||
ix = view->size.width - image->width - x;
|
||||
iy = y + (h - image->height) / 2;
|
||||
w -= image->width + 5;
|
||||
break;
|
||||
case WIPRight:
|
||||
ix = view->size.width - image->width - x;
|
||||
iy = y + (h - image->height) / 2;
|
||||
w -= image->width + 5;
|
||||
break;
|
||||
|
||||
case WIPBelow:
|
||||
ix = (view->size.width - image->width) / 2;
|
||||
iy = h - image->height;
|
||||
y = 0;
|
||||
h -= image->height;
|
||||
break;
|
||||
case WIPBelow:
|
||||
ix = (view->size.width - image->width) / 2;
|
||||
iy = h - image->height;
|
||||
y = 0;
|
||||
h -= image->height;
|
||||
break;
|
||||
|
||||
default:
|
||||
case WIPAbove:
|
||||
ix = (view->size.width - image->width) / 2;
|
||||
iy = y;
|
||||
y = image->height;
|
||||
h -= image->height;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case WIPAbove:
|
||||
ix = (view->size.width - image->width) / 2;
|
||||
iy = y;
|
||||
y = image->height;
|
||||
h -= image->height;
|
||||
break;
|
||||
}
|
||||
|
||||
ix += ofs;
|
||||
iy += ofs;
|
||||
ix += ofs;
|
||||
iy += ofs;
|
||||
|
||||
XSetClipOrigin(screen->display, screen->clipGC, ix, iy);
|
||||
XSetClipMask(screen->display, screen->clipGC, image->mask);
|
||||
XSetClipOrigin(screen->display, screen->clipGC, ix, iy);
|
||||
XSetClipMask(screen->display, screen->clipGC, image->mask);
|
||||
|
||||
if (image->depth==1)
|
||||
XCopyPlane(screen->display, image->pixmap, d, screen->clipGC,
|
||||
0, 0, image->width, image->height, ix, iy, 1);
|
||||
else
|
||||
XCopyArea(screen->display, image->pixmap, d, screen->clipGC,
|
||||
0, 0, image->width, image->height, ix, iy);
|
||||
if (image->depth==1)
|
||||
XCopyPlane(screen->display, image->pixmap, d, screen->clipGC,
|
||||
0, 0, image->width, image->height, ix, iy, 1);
|
||||
else
|
||||
XCopyArea(screen->display, image->pixmap, d, screen->clipGC,
|
||||
0, 0, image->width, image->height, ix, iy);
|
||||
}
|
||||
|
||||
/* draw text */
|
||||
if (position != WIPImageOnly && text!=NULL) {
|
||||
int textHeight;
|
||||
int textHeight;
|
||||
|
||||
textHeight = W_GetTextHeight(font, text, w-8, wrap);
|
||||
W_PaintText(view, d, font, x+ofs+4, y+ofs + (h-textHeight)/2, w-8,
|
||||
alignment, textColor, wrap, text, strlen(text));
|
||||
textHeight = W_GetTextHeight(font, text, w-8, wrap);
|
||||
W_PaintText(view, d, font, x+ofs+4, y+ofs + (h-textHeight)/2, w-8,
|
||||
alignment, textColor, wrap, text, strlen(text));
|
||||
}
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor, W_Font *font,
|
||||
|
||||
#ifdef DOUBLE_BUFFER
|
||||
XCopyArea(screen->display, d, view->window, screen->copyGC, 0, 0,
|
||||
view->size.width, view->size.height, 0, 0);
|
||||
view->size.width, view->size.height, 0, 0);
|
||||
XFreePixmap(screen->display, d);
|
||||
#endif
|
||||
}
|
||||
|
||||
+524
-524
File diff suppressed because it is too large.
Load diff
+68
-67
@@ -8,7 +8,7 @@ WMPixmap*
|
||||
WMRetainPixmap(WMPixmap *pixmap)
|
||||
{
|
||||
if (pixmap)
|
||||
pixmap->refCount++;
|
||||
pixmap->refCount++;
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
@@ -22,11 +22,11 @@ WMReleasePixmap(WMPixmap *pixmap)
|
||||
pixmap->refCount--;
|
||||
|
||||
if (pixmap->refCount<1) {
|
||||
if (pixmap->pixmap)
|
||||
XFreePixmap(pixmap->screen->display, pixmap->pixmap);
|
||||
if (pixmap->mask)
|
||||
XFreePixmap(pixmap->screen->display, pixmap->mask);
|
||||
wfree(pixmap);
|
||||
if (pixmap->pixmap)
|
||||
XFreePixmap(pixmap->screen->display, pixmap->pixmap);
|
||||
if (pixmap->mask)
|
||||
XFreePixmap(pixmap->screen->display, pixmap->mask);
|
||||
wfree(pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,21 +44,21 @@ WMCreatePixmap(WMScreen *scrPtr, int width, int height, int depth, Bool masked)
|
||||
pixPtr->refCount = 1;
|
||||
|
||||
pixPtr->pixmap = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr),
|
||||
width, height, depth);
|
||||
width, height, depth);
|
||||
if (masked) {
|
||||
pixPtr->mask = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr),
|
||||
width, height, 1);
|
||||
} else {
|
||||
pixPtr->mask = None;
|
||||
pixPtr->mask = None;
|
||||
}
|
||||
|
||||
return pixPtr;
|
||||
return pixPtr;
|
||||
}
|
||||
|
||||
|
||||
WMPixmap*
|
||||
WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap, Pixmap mask,
|
||||
int width, int height, int depth)
|
||||
int width, int height, int depth)
|
||||
{
|
||||
WMPixmap *pixPtr;
|
||||
|
||||
@@ -70,7 +70,7 @@ WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap, Pixmap mask,
|
||||
pixPtr->height = height;
|
||||
pixPtr->depth = depth;
|
||||
pixPtr->refCount = 1;
|
||||
|
||||
|
||||
return pixPtr;
|
||||
}
|
||||
|
||||
@@ -80,15 +80,15 @@ WMCreatePixmapFromFile(WMScreen *scrPtr, char *fileName)
|
||||
{
|
||||
WMPixmap *pixPtr;
|
||||
RImage *image;
|
||||
|
||||
|
||||
image = RLoadImage(scrPtr->rcontext, fileName, 0);
|
||||
if (!image)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127);
|
||||
|
||||
RReleaseImage(image);
|
||||
|
||||
|
||||
return pixPtr;
|
||||
}
|
||||
|
||||
@@ -99,11 +99,11 @@ WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image, int threshold)
|
||||
WMPixmap *pixPtr;
|
||||
Pixmap pixmap, mask;
|
||||
|
||||
if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask,
|
||||
threshold)) {
|
||||
return NULL;
|
||||
if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask,
|
||||
threshold)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pixPtr = wmalloc(sizeof(WMPixmap));
|
||||
pixPtr->screen = scrPtr;
|
||||
pixPtr->pixmap = pixmap;
|
||||
@@ -113,7 +113,7 @@ WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image, int threshold)
|
||||
pixPtr->depth = scrPtr->depth;
|
||||
pixPtr->refCount = 1;
|
||||
|
||||
return pixPtr;
|
||||
return pixPtr;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,17 +141,17 @@ WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName, RColor *color)
|
||||
WMPixmap *pixPtr;
|
||||
RImage *image;
|
||||
|
||||
|
||||
|
||||
image = RLoadImage(scrPtr->rcontext, fileName, 0);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
RCombineImageWithColor(image, color);
|
||||
|
||||
pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0);
|
||||
|
||||
|
||||
RReleaseImage(image);
|
||||
|
||||
|
||||
return pixPtr;
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ WMCreatePixmapFromXPMData(WMScreen *scrPtr, char **data)
|
||||
|
||||
image = RGetImageFromXPMData(scrPtr->rcontext, data);
|
||||
if (!image)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
|
||||
pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127);
|
||||
|
||||
RReleaseImage(image);
|
||||
|
||||
|
||||
return pixPtr;
|
||||
}
|
||||
|
||||
@@ -192,13 +192,13 @@ WMGetPixmapMaskXID(WMPixmap *pixmap)
|
||||
}
|
||||
|
||||
|
||||
WMSize
|
||||
WMSize
|
||||
WMGetPixmapSize(WMPixmap *pixmap)
|
||||
{
|
||||
WMSize size = {0,0};
|
||||
|
||||
wassertrv(pixmap != NULL, size);
|
||||
|
||||
|
||||
size.width = pixmap->width;
|
||||
size.height = pixmap->height;
|
||||
|
||||
@@ -210,44 +210,44 @@ WMPixmap*
|
||||
WMGetSystemPixmap(WMScreen *scr, int image)
|
||||
{
|
||||
switch (image) {
|
||||
case WSIReturnArrow:
|
||||
return WMRetainPixmap(scr->buttonArrow);
|
||||
|
||||
case WSIHighlightedReturnArrow:
|
||||
return WMRetainPixmap(scr->pushedButtonArrow);
|
||||
|
||||
case WSIScrollerDimple:
|
||||
return WMRetainPixmap(scr->scrollerDimple);
|
||||
|
||||
case WSIArrowLeft:
|
||||
return WMRetainPixmap(scr->leftArrow);
|
||||
|
||||
case WSIHighlightedArrowLeft:
|
||||
return WMRetainPixmap(scr->hiLeftArrow);
|
||||
|
||||
case WSIArrowRight:
|
||||
return WMRetainPixmap(scr->rightArrow);
|
||||
|
||||
case WSIHighlightedArrowRight:
|
||||
return WMRetainPixmap(scr->hiRightArrow);
|
||||
|
||||
case WSIArrowUp:
|
||||
return WMRetainPixmap(scr->upArrow);
|
||||
|
||||
case WSIHighlightedArrowUp:
|
||||
return WMRetainPixmap(scr->hiUpArrow);
|
||||
|
||||
case WSIArrowDown:
|
||||
return WMRetainPixmap(scr->downArrow);
|
||||
|
||||
case WSIHighlightedArrowDown:
|
||||
return WMRetainPixmap(scr->hiDownArrow);
|
||||
case WSIReturnArrow:
|
||||
return WMRetainPixmap(scr->buttonArrow);
|
||||
|
||||
case WSICheckMark:
|
||||
return WMRetainPixmap(scr->checkMark);
|
||||
case WSIHighlightedReturnArrow:
|
||||
return WMRetainPixmap(scr->pushedButtonArrow);
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
case WSIScrollerDimple:
|
||||
return WMRetainPixmap(scr->scrollerDimple);
|
||||
|
||||
case WSIArrowLeft:
|
||||
return WMRetainPixmap(scr->leftArrow);
|
||||
|
||||
case WSIHighlightedArrowLeft:
|
||||
return WMRetainPixmap(scr->hiLeftArrow);
|
||||
|
||||
case WSIArrowRight:
|
||||
return WMRetainPixmap(scr->rightArrow);
|
||||
|
||||
case WSIHighlightedArrowRight:
|
||||
return WMRetainPixmap(scr->hiRightArrow);
|
||||
|
||||
case WSIArrowUp:
|
||||
return WMRetainPixmap(scr->upArrow);
|
||||
|
||||
case WSIHighlightedArrowUp:
|
||||
return WMRetainPixmap(scr->hiUpArrow);
|
||||
|
||||
case WSIArrowDown:
|
||||
return WMRetainPixmap(scr->downArrow);
|
||||
|
||||
case WSIHighlightedArrowDown:
|
||||
return WMRetainPixmap(scr->hiDownArrow);
|
||||
|
||||
case WSICheckMark:
|
||||
return WMRetainPixmap(scr->checkMark);
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,6 +261,7 @@ WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y)
|
||||
XSetClipMask(scr->display, scr->clipGC, pixmap->mask);
|
||||
XSetClipOrigin(scr->display, scr->clipGC, x, y);
|
||||
|
||||
XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0,
|
||||
pixmap->width, pixmap->height, x, y);
|
||||
XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0,
|
||||
pixmap->width, pixmap->height, x, y);
|
||||
}
|
||||
|
||||
+284
-282
@@ -8,33 +8,33 @@
|
||||
typedef struct W_PopUpButton {
|
||||
W_Class widgetClass;
|
||||
WMView *view;
|
||||
|
||||
|
||||
void *clientData;
|
||||
WMAction *action;
|
||||
|
||||
char *caption;
|
||||
|
||||
WMArray *items;
|
||||
|
||||
|
||||
short selectedItemIndex;
|
||||
|
||||
|
||||
short highlightedItem;
|
||||
|
||||
|
||||
WMView *menuView; /* override redirect popup menu */
|
||||
|
||||
WMHandlerID timer; /* for autoscroll */
|
||||
|
||||
/**/
|
||||
int scrollStartY; /* for autoscroll */
|
||||
|
||||
struct {
|
||||
unsigned int pullsDown:1;
|
||||
|
||||
unsigned int configured:1;
|
||||
|
||||
unsigned int insideMenu:1;
|
||||
|
||||
unsigned int enabled:1;
|
||||
struct {
|
||||
unsigned int pullsDown:1;
|
||||
|
||||
unsigned int configured:1;
|
||||
|
||||
unsigned int insideMenu:1;
|
||||
|
||||
unsigned int enabled:1;
|
||||
|
||||
} flags;
|
||||
} PopUpButton;
|
||||
@@ -59,38 +59,38 @@ static void handleActionEvents(XEvent *event, void *data);
|
||||
|
||||
static void resizeMenu(PopUpButton *bPtr);
|
||||
|
||||
|
||||
|
||||
WMPopUpButton*
|
||||
WMCreatePopUpButton(WMWidget *parent)
|
||||
{
|
||||
PopUpButton *bPtr;
|
||||
W_Screen *scr = W_VIEW(parent)->screen;
|
||||
|
||||
|
||||
|
||||
bPtr = wmalloc(sizeof(PopUpButton));
|
||||
memset(bPtr, 0, sizeof(PopUpButton));
|
||||
|
||||
bPtr->widgetClass = WC_PopUpButton;
|
||||
|
||||
|
||||
bPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!bPtr->view) {
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
wfree(bPtr);
|
||||
return NULL;
|
||||
}
|
||||
bPtr->view->self = bPtr;
|
||||
|
||||
|
||||
WMCreateEventHandler(bPtr->view, ExposureMask|StructureNotifyMask
|
||||
|ClientMessageMask, handleEvents, bPtr);
|
||||
|ClientMessageMask, handleEvents, bPtr);
|
||||
|
||||
|
||||
W_ResizeView(bPtr->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
bPtr->caption = wstrdup(DEFAULT_CAPTION);
|
||||
|
||||
WMCreateEventHandler(bPtr->view, ButtonPressMask|ButtonReleaseMask,
|
||||
handleActionEvents, bPtr);
|
||||
handleActionEvents, bPtr);
|
||||
|
||||
bPtr->flags.enabled = 1;
|
||||
|
||||
|
||||
bPtr->items =
|
||||
WMCreateArrayWithDestructor(4, (WMFreeDataProc*)WMDestroyMenuItem);
|
||||
|
||||
@@ -101,8 +101,8 @@ WMCreatePopUpButton(WMWidget *parent)
|
||||
W_ResizeView(bPtr->menuView, bPtr->view->size.width, 1);
|
||||
|
||||
WMCreateEventHandler(bPtr->menuView, ButtonPressMask|ButtonReleaseMask
|
||||
|EnterWindowMask|LeaveWindowMask|ButtonMotionMask
|
||||
|ExposureMask, handleActionEvents, bPtr);
|
||||
|EnterWindowMask|LeaveWindowMask|ButtonMotionMask
|
||||
|ExposureMask, handleActionEvents, bPtr);
|
||||
|
||||
return bPtr;
|
||||
}
|
||||
@@ -112,9 +112,9 @@ void
|
||||
WMSetPopUpButtonAction(WMPopUpButton *bPtr, WMAction *action, void *clientData)
|
||||
{
|
||||
CHECK_CLASS(bPtr, WC_PopUpButton);
|
||||
|
||||
|
||||
bPtr->action = action;
|
||||
|
||||
|
||||
bPtr->clientData = clientData;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ WMMenuItem*
|
||||
WMAddPopUpButtonItem(WMPopUpButton *bPtr, char *title)
|
||||
{
|
||||
WMMenuItem *item;
|
||||
|
||||
|
||||
CHECK_CLASS(bPtr, WC_PopUpButton);
|
||||
|
||||
item = WMCreateMenuItem();
|
||||
@@ -132,7 +132,7 @@ WMAddPopUpButtonItem(WMPopUpButton *bPtr, char *title)
|
||||
WMAddToArray(bPtr->items, item);
|
||||
|
||||
if (bPtr->menuView && bPtr->menuView->flags.realized)
|
||||
resizeMenu(bPtr);
|
||||
resizeMenu(bPtr);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -144,20 +144,20 @@ WMInsertPopUpButtonItem(WMPopUpButton *bPtr, int index, char *title)
|
||||
WMMenuItem *item;
|
||||
|
||||
CHECK_CLASS(bPtr, WC_PopUpButton);
|
||||
|
||||
|
||||
item = WMCreateMenuItem();
|
||||
WMSetMenuItemTitle(item, title);
|
||||
|
||||
WMInsertInArray(bPtr->items, index, item);
|
||||
|
||||
/* if there is an selected item, update it's index to match the new
|
||||
|
||||
/* if there is an selected item, update it's index to match the new
|
||||
* position */
|
||||
if (index < bPtr->selectedItemIndex)
|
||||
bPtr->selectedItemIndex++;
|
||||
|
||||
bPtr->selectedItemIndex++;
|
||||
|
||||
if (bPtr->menuView && bPtr->menuView->flags.realized)
|
||||
resizeMenu(bPtr);
|
||||
|
||||
resizeMenu(bPtr);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -173,19 +173,19 @@ WMRemovePopUpButtonItem(WMPopUpButton *bPtr, int index)
|
||||
WMDeleteFromArray(bPtr->items, index);
|
||||
|
||||
if (bPtr->selectedItemIndex >= 0 && !bPtr->flags.pullsDown) {
|
||||
if (index < bPtr->selectedItemIndex)
|
||||
bPtr->selectedItemIndex--;
|
||||
else if (index == bPtr->selectedItemIndex) {
|
||||
/* reselect first item if the removed item is the
|
||||
* selected one */
|
||||
bPtr->selectedItemIndex = 0;
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
if (index < bPtr->selectedItemIndex)
|
||||
bPtr->selectedItemIndex--;
|
||||
else if (index == bPtr->selectedItemIndex) {
|
||||
/* reselect first item if the removed item is the
|
||||
* selected one */
|
||||
bPtr->selectedItemIndex = 0;
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bPtr->menuView && bPtr->menuView->flags.realized)
|
||||
resizeMenu(bPtr);
|
||||
resizeMenu(bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ WMSetPopUpButtonEnabled(WMPopUpButton *bPtr, Bool flag)
|
||||
{
|
||||
bPtr->flags.enabled = ((flag==0) ? 0 : 1);
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintPopUpButton(bPtr);
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,12 +212,12 @@ WMSetPopUpButtonSelectedItem(WMPopUpButton *bPtr, int index)
|
||||
wassertr(index < WMGetArrayItemCount(bPtr->items));
|
||||
|
||||
/* if (index >= WMGetArrayCount(bPtr->items))
|
||||
index = -1;*/
|
||||
index = -1;*/
|
||||
|
||||
bPtr->selectedItemIndex = index;
|
||||
|
||||
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintPopUpButton(bPtr);
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,9 +225,9 @@ int
|
||||
WMGetPopUpButtonSelectedItem(WMPopUpButton *bPtr)
|
||||
{
|
||||
if (!bPtr->flags.pullsDown && bPtr->selectedItemIndex < 0)
|
||||
return -1;
|
||||
return -1;
|
||||
else
|
||||
return bPtr->selectedItemIndex;
|
||||
return bPtr->selectedItemIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,21 +235,21 @@ void
|
||||
WMSetPopUpButtonText(WMPopUpButton *bPtr, char *text)
|
||||
{
|
||||
if (bPtr->caption)
|
||||
wfree(bPtr->caption);
|
||||
wfree(bPtr->caption);
|
||||
if (text)
|
||||
bPtr->caption = wstrdup(text);
|
||||
bPtr->caption = wstrdup(text);
|
||||
else
|
||||
bPtr->caption = NULL;
|
||||
bPtr->caption = NULL;
|
||||
if (bPtr->view->flags.realized) {
|
||||
if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0) {
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
if (bPtr->flags.pullsDown || bPtr->selectedItemIndex < 0) {
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
WMSetPopUpButtonItemEnabled(WMPopUpButton *bPtr, int index, Bool flag)
|
||||
{
|
||||
WMSetMenuItemEnabled(WMGetFromArray(bPtr->items, index), (flag ? 1 : 0));
|
||||
@@ -268,11 +268,11 @@ WMSetPopUpButtonPullsDown(WMPopUpButton *bPtr, Bool flag)
|
||||
{
|
||||
bPtr->flags.pullsDown = ((flag==0) ? 0 : 1);
|
||||
if (flag) {
|
||||
bPtr->selectedItemIndex = -1;
|
||||
bPtr->selectedItemIndex = -1;
|
||||
}
|
||||
|
||||
if (bPtr->view->flags.mapped)
|
||||
paintPopUpButton(bPtr);
|
||||
paintPopUpButton(bPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ char*
|
||||
WMGetPopUpButtonItem(WMPopUpButton *bPtr, int index)
|
||||
{
|
||||
if (index >= WMGetArrayItemCount(bPtr->items) || index < 0)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
return WMGetMenuItemTitle(WMGetFromArray(bPtr->items, index));
|
||||
}
|
||||
@@ -308,57 +308,57 @@ paintPopUpButton(PopUpButton *bPtr)
|
||||
char *caption;
|
||||
Pixmap pixmap;
|
||||
|
||||
|
||||
|
||||
if (bPtr->flags.pullsDown) {
|
||||
caption = bPtr->caption;
|
||||
caption = bPtr->caption;
|
||||
} else {
|
||||
if (bPtr->selectedItemIndex < 0) {
|
||||
/* if no item selected, show the caption */
|
||||
caption = bPtr->caption;
|
||||
} else {
|
||||
caption = WMGetPopUpButtonItem(bPtr, bPtr->selectedItemIndex);
|
||||
}
|
||||
if (bPtr->selectedItemIndex < 0) {
|
||||
/* if no item selected, show the caption */
|
||||
caption = bPtr->caption;
|
||||
} else {
|
||||
caption = WMGetPopUpButtonItem(bPtr, bPtr->selectedItemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
pixmap = XCreatePixmap(scr->display, bPtr->view->window,
|
||||
bPtr->view->size.width, bPtr->view->size.height,
|
||||
scr->depth);
|
||||
pixmap = XCreatePixmap(scr->display, bPtr->view->window,
|
||||
bPtr->view->size.width, bPtr->view->size.height,
|
||||
scr->depth);
|
||||
XFillRectangle(scr->display, pixmap, WMColorGC(scr->gray), 0, 0,
|
||||
bPtr->view->size.width, bPtr->view->size.height);
|
||||
bPtr->view->size.width, bPtr->view->size.height);
|
||||
|
||||
W_DrawRelief(scr, pixmap, 0, 0, bPtr->view->size.width,
|
||||
bPtr->view->size.height, WRRaised);
|
||||
bPtr->view->size.height, WRRaised);
|
||||
|
||||
if (caption) {
|
||||
W_PaintText(bPtr->view, pixmap, scr->normalFont, 6,
|
||||
(bPtr->view->size.height-WMFontHeight(scr->normalFont))/2,
|
||||
bPtr->view->size.width, WALeft,
|
||||
bPtr->flags.enabled ? scr->black : scr->darkGray,
|
||||
False, caption, strlen(caption));
|
||||
W_PaintText(bPtr->view, pixmap, scr->normalFont, 6,
|
||||
(bPtr->view->size.height-WMFontHeight(scr->normalFont))/2,
|
||||
bPtr->view->size.width, WALeft,
|
||||
bPtr->flags.enabled ? scr->black : scr->darkGray,
|
||||
False, caption, strlen(caption));
|
||||
}
|
||||
|
||||
if (bPtr->flags.pullsDown) {
|
||||
XCopyArea(scr->display, scr->pullDownIndicator->pixmap,
|
||||
pixmap, scr->copyGC, 0, 0, scr->pullDownIndicator->width,
|
||||
scr->pullDownIndicator->height,
|
||||
bPtr->view->size.width-scr->pullDownIndicator->width-4,
|
||||
(bPtr->view->size.height-scr->pullDownIndicator->height)/2);
|
||||
XCopyArea(scr->display, scr->pullDownIndicator->pixmap,
|
||||
pixmap, scr->copyGC, 0, 0, scr->pullDownIndicator->width,
|
||||
scr->pullDownIndicator->height,
|
||||
bPtr->view->size.width-scr->pullDownIndicator->width-4,
|
||||
(bPtr->view->size.height-scr->pullDownIndicator->height)/2);
|
||||
} else {
|
||||
int x, y;
|
||||
|
||||
x = bPtr->view->size.width - scr->popUpIndicator->width - 4;
|
||||
y = (bPtr->view->size.height-scr->popUpIndicator->height)/2;
|
||||
|
||||
XSetClipOrigin(scr->display, scr->clipGC, x, y);
|
||||
XSetClipMask(scr->display, scr->clipGC, scr->popUpIndicator->mask);
|
||||
XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap,
|
||||
scr->clipGC, 0, 0, scr->popUpIndicator->width,
|
||||
scr->popUpIndicator->height, x, y);
|
||||
int x, y;
|
||||
|
||||
x = bPtr->view->size.width - scr->popUpIndicator->width - 4;
|
||||
y = (bPtr->view->size.height-scr->popUpIndicator->height)/2;
|
||||
|
||||
XSetClipOrigin(scr->display, scr->clipGC, x, y);
|
||||
XSetClipMask(scr->display, scr->clipGC, scr->popUpIndicator->mask);
|
||||
XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap,
|
||||
scr->clipGC, 0, 0, scr->popUpIndicator->width,
|
||||
scr->popUpIndicator->height, x, y);
|
||||
}
|
||||
|
||||
XCopyArea(scr->display, pixmap, bPtr->view->window, scr->copyGC, 0, 0,
|
||||
bPtr->view->size.width, bPtr->view->size.height, 0, 0);
|
||||
|
||||
bPtr->view->size.width, bPtr->view->size.height, 0, 0);
|
||||
|
||||
XFreePixmap(scr->display, pixmap);
|
||||
}
|
||||
|
||||
@@ -373,15 +373,15 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintPopUpButton(bPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyPopUpButton(bPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintPopUpButton(bPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyPopUpButton(bPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,31 +405,31 @@ paintMenuEntry(PopUpButton *bPtr, int index, int highlight)
|
||||
yo = (itemHeight - WMFontHeight(scr->normalFont))/2;
|
||||
|
||||
if (!highlight) {
|
||||
XClearArea(scr->display, bPtr->menuView->window, 0, index*itemHeight,
|
||||
width, itemHeight, False);
|
||||
return;
|
||||
XClearArea(scr->display, bPtr->menuView->window, 0, index*itemHeight,
|
||||
width, itemHeight, False);
|
||||
return;
|
||||
} else if (index < 0 && bPtr->flags.pullsDown) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
XFillRectangle(scr->display, bPtr->menuView->window, WMColorGC(scr->white),
|
||||
1, index*itemHeight+1, width-3, itemHeight-3);
|
||||
|
||||
1, index*itemHeight+1, width-3, itemHeight-3);
|
||||
|
||||
title = WMGetPopUpButtonItem(bPtr, index);
|
||||
|
||||
W_DrawRelief(scr, bPtr->menuView->window, 0, index*itemHeight,
|
||||
width, itemHeight, WRRaised);
|
||||
W_DrawRelief(scr, bPtr->menuView->window, 0, index*itemHeight,
|
||||
width, itemHeight, WRRaised);
|
||||
|
||||
W_PaintText(bPtr->menuView, bPtr->menuView->window, scr->normalFont, 6,
|
||||
index*itemHeight + yo, width, WALeft, scr->black,
|
||||
False, title, strlen(title));
|
||||
W_PaintText(bPtr->menuView, bPtr->menuView->window, scr->normalFont, 6,
|
||||
index*itemHeight + yo, width, WALeft, scr->black,
|
||||
False, title, strlen(title));
|
||||
|
||||
if (!bPtr->flags.pullsDown && index == bPtr->selectedItemIndex) {
|
||||
XCopyArea(scr->display, scr->popUpIndicator->pixmap,
|
||||
bPtr->menuView->window, scr->copyGC, 0, 0,
|
||||
scr->popUpIndicator->width, scr->popUpIndicator->height,
|
||||
width-scr->popUpIndicator->width-4,
|
||||
index*itemHeight+(itemHeight-scr->popUpIndicator->height)/2);
|
||||
XCopyArea(scr->display, scr->popUpIndicator->pixmap,
|
||||
bPtr->menuView->window, scr->copyGC, 0, 0,
|
||||
scr->popUpIndicator->width, scr->popUpIndicator->height,
|
||||
width-scr->popUpIndicator->width-4,
|
||||
index*itemHeight+(itemHeight-scr->popUpIndicator->height)/2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,48 +443,48 @@ makeMenuPixmap(PopUpButton *bPtr)
|
||||
WMArrayIterator iter;
|
||||
int yo, i;
|
||||
int width, height, itemHeight;
|
||||
|
||||
|
||||
itemHeight = bPtr->view->size.height;
|
||||
width = bPtr->view->size.width;
|
||||
height = itemHeight * WMGetArrayItemCount(bPtr->items);
|
||||
yo = (itemHeight - WMFontHeight(scr->normalFont))/2;
|
||||
|
||||
pixmap = XCreatePixmap(scr->display, bPtr->view->window, width, height,
|
||||
scr->depth);
|
||||
|
||||
|
||||
pixmap = XCreatePixmap(scr->display, bPtr->view->window, width, height,
|
||||
scr->depth);
|
||||
|
||||
XFillRectangle(scr->display, pixmap, WMColorGC(scr->gray), 0, 0,
|
||||
width, height);
|
||||
width, height);
|
||||
|
||||
i = 0;
|
||||
WM_ITERATE_ARRAY(bPtr->items, item, iter) {
|
||||
WMColor *color;
|
||||
char *text;
|
||||
WMColor *color;
|
||||
char *text;
|
||||
|
||||
text = WMGetMenuItemTitle(item);
|
||||
text = WMGetMenuItemTitle(item);
|
||||
|
||||
W_DrawRelief(scr, pixmap, 0, i*itemHeight, width, itemHeight,
|
||||
WRRaised);
|
||||
W_DrawRelief(scr, pixmap, 0, i*itemHeight, width, itemHeight,
|
||||
WRRaised);
|
||||
|
||||
if (!WMGetMenuItemEnabled(item))
|
||||
color = scr->darkGray;
|
||||
else
|
||||
color = scr->black;
|
||||
color = scr->darkGray;
|
||||
else
|
||||
color = scr->black;
|
||||
|
||||
W_PaintText(bPtr->menuView, pixmap, scr->normalFont, 6,
|
||||
i*itemHeight + yo, width, WALeft, color, False,
|
||||
text, strlen(text));
|
||||
|
||||
if (!bPtr->flags.pullsDown && i == bPtr->selectedItemIndex) {
|
||||
XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap,
|
||||
scr->copyGC, 0, 0, scr->popUpIndicator->width,
|
||||
scr->popUpIndicator->height,
|
||||
width-scr->popUpIndicator->width-4,
|
||||
i*itemHeight+(itemHeight-scr->popUpIndicator->height)/2);
|
||||
}
|
||||
|
||||
i++;
|
||||
W_PaintText(bPtr->menuView, pixmap, scr->normalFont, 6,
|
||||
i*itemHeight + yo, width, WALeft, color, False,
|
||||
text, strlen(text));
|
||||
|
||||
if (!bPtr->flags.pullsDown && i == bPtr->selectedItemIndex) {
|
||||
XCopyArea(scr->display, scr->popUpIndicator->pixmap, pixmap,
|
||||
scr->copyGC, 0, 0, scr->popUpIndicator->width,
|
||||
scr->popUpIndicator->height,
|
||||
width-scr->popUpIndicator->width-4,
|
||||
i*itemHeight+(itemHeight-scr->popUpIndicator->height)/2);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
@@ -493,10 +493,10 @@ static void
|
||||
resizeMenu(PopUpButton *bPtr)
|
||||
{
|
||||
int height;
|
||||
|
||||
|
||||
height = WMGetArrayItemCount(bPtr->items) * bPtr->view->size.height;
|
||||
if (height > 0)
|
||||
W_ResizeView(bPtr->menuView, bPtr->view->size.width, height);
|
||||
W_ResizeView(bPtr->menuView, bPtr->view->size.width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -508,38 +508,38 @@ popUpMenu(PopUpButton *bPtr)
|
||||
int x, y;
|
||||
|
||||
if (!bPtr->flags.enabled)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
if (!bPtr->menuView->flags.realized) {
|
||||
W_RealizeView(bPtr->menuView);
|
||||
resizeMenu(bPtr);
|
||||
W_RealizeView(bPtr->menuView);
|
||||
resizeMenu(bPtr);
|
||||
}
|
||||
|
||||
|
||||
if (WMGetArrayItemCount(bPtr->items) < 1)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
XTranslateCoordinates(scr->display, bPtr->view->window, scr->rootWin,
|
||||
0, 0, &x, &y, &dummyW);
|
||||
0, 0, &x, &y, &dummyW);
|
||||
|
||||
if (bPtr->flags.pullsDown) {
|
||||
y += bPtr->view->size.height;
|
||||
y += bPtr->view->size.height;
|
||||
} else {
|
||||
y -= bPtr->view->size.height*bPtr->selectedItemIndex;
|
||||
y -= bPtr->view->size.height*bPtr->selectedItemIndex;
|
||||
}
|
||||
W_MoveView(bPtr->menuView, x, y);
|
||||
|
||||
|
||||
XSetWindowBackgroundPixmap(scr->display, bPtr->menuView->window,
|
||||
makeMenuPixmap(bPtr));
|
||||
makeMenuPixmap(bPtr));
|
||||
XClearWindow(scr->display, bPtr->menuView->window);
|
||||
|
||||
|
||||
if (W_VIEW_WIDTH(bPtr->menuView) != W_VIEW_WIDTH(bPtr->view))
|
||||
resizeMenu(bPtr);
|
||||
|
||||
resizeMenu(bPtr);
|
||||
|
||||
W_MapView(bPtr->menuView);
|
||||
|
||||
|
||||
bPtr->highlightedItem = 0;
|
||||
if (!bPtr->flags.pullsDown && bPtr->selectedItemIndex < 0)
|
||||
paintMenuEntry(bPtr, bPtr->selectedItemIndex, True);
|
||||
paintMenuEntry(bPtr, bPtr->selectedItemIndex, True);
|
||||
}
|
||||
|
||||
|
||||
@@ -560,39 +560,39 @@ autoScroll(void *data)
|
||||
|
||||
|
||||
if (bPtr->scrollStartY >= scrHeight-1
|
||||
&& bPtr->menuView->pos.y+bPtr->menuView->size.height >= scrHeight-1) {
|
||||
repeat = 1;
|
||||
&& bPtr->menuView->pos.y+bPtr->menuView->size.height >= scrHeight-1) {
|
||||
repeat = 1;
|
||||
|
||||
if (bPtr->menuView->pos.y+bPtr->menuView->size.height-5
|
||||
<= scrHeight - 1) {
|
||||
dy = scrHeight - 1
|
||||
- (bPtr->menuView->pos.y+bPtr->menuView->size.height);
|
||||
} else
|
||||
dy = -5;
|
||||
if (bPtr->menuView->pos.y+bPtr->menuView->size.height-5
|
||||
<= scrHeight - 1) {
|
||||
dy = scrHeight - 1
|
||||
- (bPtr->menuView->pos.y+bPtr->menuView->size.height);
|
||||
} else
|
||||
dy = -5;
|
||||
|
||||
} else if (bPtr->scrollStartY <= 1 && bPtr->menuView->pos.y < 1) {
|
||||
repeat = 1;
|
||||
repeat = 1;
|
||||
|
||||
if (bPtr->menuView->pos.y+5 > 1)
|
||||
dy = 1 - bPtr->menuView->pos.y;
|
||||
else
|
||||
dy = 5;
|
||||
if (bPtr->menuView->pos.y+5 > 1)
|
||||
dy = 1 - bPtr->menuView->pos.y;
|
||||
else
|
||||
dy = 5;
|
||||
}
|
||||
|
||||
if (repeat) {
|
||||
int oldItem;
|
||||
int oldItem;
|
||||
|
||||
W_MoveView(bPtr->menuView, bPtr->menuView->pos.x,
|
||||
bPtr->menuView->pos.y + dy);
|
||||
W_MoveView(bPtr->menuView, bPtr->menuView->pos.x,
|
||||
bPtr->menuView->pos.y + dy);
|
||||
|
||||
oldItem = bPtr->highlightedItem;
|
||||
bPtr->highlightedItem = (bPtr->scrollStartY - bPtr->menuView->pos.y)
|
||||
/ bPtr->view->size.height;
|
||||
oldItem = bPtr->highlightedItem;
|
||||
bPtr->highlightedItem = (bPtr->scrollStartY - bPtr->menuView->pos.y)
|
||||
/ bPtr->view->size.height;
|
||||
|
||||
if (oldItem!=bPtr->highlightedItem) {
|
||||
if (oldItem!=bPtr->highlightedItem) {
|
||||
WMMenuItem *item;
|
||||
|
||||
paintMenuEntry(bPtr, oldItem, False);
|
||||
paintMenuEntry(bPtr, oldItem, False);
|
||||
|
||||
if (bPtr->highlightedItem >= 0 &&
|
||||
bPtr->highlightedItem < WMGetArrayItemCount(bPtr->items)) {
|
||||
@@ -602,11 +602,11 @@ autoScroll(void *data)
|
||||
} else {
|
||||
bPtr->highlightedItem = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bPtr->timer = WMAddTimerHandler(SCROLL_DELAY, autoScroll, bPtr);
|
||||
bPtr->timer = WMAddTimerHandler(SCROLL_DELAY, autoScroll, bPtr);
|
||||
} else {
|
||||
bPtr->timer = NULL;
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,7 +619,7 @@ wheelScrollUp(PopUpButton *bPtr)
|
||||
while (testIndex>=0 && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
|
||||
testIndex--;
|
||||
if (testIndex != -1) {
|
||||
WMSetPopUpButtonSelectedItem(bPtr, testIndex);
|
||||
WMSetPopUpButtonSelectedItem(bPtr, testIndex);
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
}
|
||||
@@ -633,9 +633,9 @@ wheelScrollDown(PopUpButton *bPtr)
|
||||
int testIndex = bPtr->selectedItemIndex + 1;
|
||||
|
||||
while (testIndex<itemCount && !WMGetPopUpButtonItemEnabled(bPtr, testIndex))
|
||||
testIndex++;
|
||||
testIndex++;
|
||||
if (testIndex != itemCount) {
|
||||
WMSetPopUpButtonSelectedItem(bPtr, testIndex);
|
||||
WMSetPopUpButtonSelectedItem(bPtr, testIndex);
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
}
|
||||
@@ -652,33 +652,33 @@ handleActionEvents(XEvent *event, void *data)
|
||||
CHECK_CLASS(data, WC_PopUpButton);
|
||||
|
||||
if (WMGetArrayItemCount(bPtr->items) < 1)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
switch (event->type) {
|
||||
/* called for menuView */
|
||||
case Expose:
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, True);
|
||||
break;
|
||||
/* called for menuView */
|
||||
case Expose:
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, True);
|
||||
break;
|
||||
|
||||
case LeaveNotify:
|
||||
bPtr->flags.insideMenu = 0;
|
||||
if (bPtr->menuView->flags.mapped)
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, False);
|
||||
bPtr->highlightedItem = -1;
|
||||
break;
|
||||
|
||||
case EnterNotify:
|
||||
bPtr->flags.insideMenu = 1;
|
||||
break;
|
||||
case LeaveNotify:
|
||||
bPtr->flags.insideMenu = 0;
|
||||
if (bPtr->menuView->flags.mapped)
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, False);
|
||||
bPtr->highlightedItem = -1;
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (bPtr->flags.insideMenu) {
|
||||
oldItem = bPtr->highlightedItem;
|
||||
bPtr->highlightedItem = event->xmotion.y / bPtr->view->size.height;
|
||||
if (oldItem!=bPtr->highlightedItem) {
|
||||
WMMenuItem *item;
|
||||
|
||||
paintMenuEntry(bPtr, oldItem, False);
|
||||
case EnterNotify:
|
||||
bPtr->flags.insideMenu = 1;
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (bPtr->flags.insideMenu) {
|
||||
oldItem = bPtr->highlightedItem;
|
||||
bPtr->highlightedItem = event->xmotion.y / bPtr->view->size.height;
|
||||
if (oldItem!=bPtr->highlightedItem) {
|
||||
WMMenuItem *item;
|
||||
|
||||
paintMenuEntry(bPtr, oldItem, False);
|
||||
if (bPtr->highlightedItem >= 0 &&
|
||||
bPtr->highlightedItem < WMGetArrayItemCount(bPtr->items)) {
|
||||
item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem);
|
||||
@@ -688,24 +688,24 @@ handleActionEvents(XEvent *event, void *data)
|
||||
bPtr->highlightedItem = -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (event->xmotion.y_root >= scrHeight-1
|
||||
|| event->xmotion.y_root <= 1) {
|
||||
bPtr->scrollStartY = event->xmotion.y_root;
|
||||
if (!bPtr->timer)
|
||||
autoScroll(bPtr);
|
||||
} else if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* called for bPtr->view */
|
||||
case ButtonPress:
|
||||
if (!bPtr->flags.enabled)
|
||||
break;
|
||||
if (event->xmotion.y_root >= scrHeight-1
|
||||
|| event->xmotion.y_root <= 1) {
|
||||
bPtr->scrollStartY = event->xmotion.y_root;
|
||||
if (!bPtr->timer)
|
||||
autoScroll(bPtr);
|
||||
} else if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* called for bPtr->view */
|
||||
case ButtonPress:
|
||||
if (!bPtr->flags.enabled)
|
||||
break;
|
||||
|
||||
if (event->xbutton.button==WINGsConfiguration.mouseWheelUp) {
|
||||
if (!bPtr->menuView->flags.mapped && !bPtr->flags.pullsDown) {
|
||||
@@ -719,62 +719,62 @@ handleActionEvents(XEvent *event, void *data)
|
||||
break;
|
||||
}
|
||||
popUpMenu(bPtr);
|
||||
if (!bPtr->flags.pullsDown) {
|
||||
bPtr->highlightedItem = bPtr->selectedItemIndex;
|
||||
bPtr->flags.insideMenu = 1;
|
||||
} else {
|
||||
bPtr->highlightedItem = -1;
|
||||
bPtr->flags.insideMenu = 0;
|
||||
}
|
||||
XGrabPointer(bPtr->view->screen->display, bPtr->menuView->window,
|
||||
False, ButtonReleaseMask|ButtonMotionMask|EnterWindowMask
|
||||
|LeaveWindowMask, GrabModeAsync, GrabModeAsync,
|
||||
None, None, CurrentTime);
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event->xbutton.button==WINGsConfiguration.mouseWheelUp ||
|
||||
if (!bPtr->flags.pullsDown) {
|
||||
bPtr->highlightedItem = bPtr->selectedItemIndex;
|
||||
bPtr->flags.insideMenu = 1;
|
||||
} else {
|
||||
bPtr->highlightedItem = -1;
|
||||
bPtr->flags.insideMenu = 0;
|
||||
}
|
||||
XGrabPointer(bPtr->view->screen->display, bPtr->menuView->window,
|
||||
False, ButtonReleaseMask|ButtonMotionMask|EnterWindowMask
|
||||
|LeaveWindowMask, GrabModeAsync, GrabModeAsync,
|
||||
None, None, CurrentTime);
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (event->xbutton.button==WINGsConfiguration.mouseWheelUp ||
|
||||
event->xbutton.button==WINGsConfiguration.mouseWheelDown) {
|
||||
break;
|
||||
}
|
||||
XUngrabPointer(bPtr->view->screen->display, event->xbutton.time);
|
||||
if (!bPtr->flags.pullsDown)
|
||||
popDownMenu(bPtr);
|
||||
XUngrabPointer(bPtr->view->screen->display, event->xbutton.time);
|
||||
if (!bPtr->flags.pullsDown)
|
||||
popDownMenu(bPtr);
|
||||
|
||||
if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
bPtr->timer = NULL;
|
||||
}
|
||||
|
||||
if (bPtr->flags.insideMenu && bPtr->highlightedItem>=0) {
|
||||
WMMenuItem *item;
|
||||
if (bPtr->flags.insideMenu && bPtr->highlightedItem>=0) {
|
||||
WMMenuItem *item;
|
||||
|
||||
item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem);
|
||||
item = WMGetPopUpButtonMenuItem(bPtr, bPtr->highlightedItem);
|
||||
|
||||
if (WMGetMenuItemEnabled(item)) {
|
||||
int i;
|
||||
int i;
|
||||
WMSetPopUpButtonSelectedItem(bPtr, bPtr->highlightedItem);
|
||||
|
||||
if (bPtr->flags.pullsDown) {
|
||||
for (i=0; i<MENU_BLINK_COUNT; i++) {
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, False);
|
||||
XSync(bPtr->view->screen->display, 0);
|
||||
wusleep(MENU_BLINK_DELAY);
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, True);
|
||||
XSync(bPtr->view->screen->display, 0);
|
||||
wusleep(MENU_BLINK_DELAY);
|
||||
}
|
||||
}
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, False);
|
||||
popDownMenu(bPtr);
|
||||
if (bPtr->flags.pullsDown) {
|
||||
for (i=0; i<MENU_BLINK_COUNT; i++) {
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, False);
|
||||
XSync(bPtr->view->screen->display, 0);
|
||||
wusleep(MENU_BLINK_DELAY);
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, True);
|
||||
XSync(bPtr->view->screen->display, 0);
|
||||
wusleep(MENU_BLINK_DELAY);
|
||||
}
|
||||
}
|
||||
paintMenuEntry(bPtr, bPtr->highlightedItem, False);
|
||||
popDownMenu(bPtr);
|
||||
if (bPtr->action)
|
||||
(*bPtr->action)(bPtr, bPtr->clientData);
|
||||
}
|
||||
}
|
||||
if (bPtr->menuView->flags.mapped)
|
||||
popDownMenu(bPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bPtr->menuView->flags.mapped)
|
||||
popDownMenu(bPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -783,16 +783,18 @@ static void
|
||||
destroyPopUpButton(PopUpButton *bPtr)
|
||||
{
|
||||
if (bPtr->timer) {
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
WMDeleteTimerHandler(bPtr->timer);
|
||||
}
|
||||
|
||||
WMFreeArray(bPtr->items);
|
||||
|
||||
if (bPtr->caption)
|
||||
wfree(bPtr->caption);
|
||||
wfree(bPtr->caption);
|
||||
|
||||
/* have to destroy explicitly because the popup is a toplevel */
|
||||
W_DestroyView(bPtr->menuView);
|
||||
|
||||
wfree(bPtr);
|
||||
}
|
||||
|
||||
|
||||
+89
-89
@@ -10,11 +10,11 @@
|
||||
typedef struct W_ProgressIndicator {
|
||||
W_Class widgetClass;
|
||||
W_View *view;
|
||||
|
||||
|
||||
int value;
|
||||
int minValue;
|
||||
int maxValue;
|
||||
|
||||
|
||||
void *clientData;
|
||||
} ProgressIndicator;
|
||||
|
||||
@@ -48,34 +48,34 @@ WMProgressIndicator*
|
||||
WMCreateProgressIndicator(WMWidget *parent)
|
||||
{
|
||||
ProgressIndicator *pPtr;
|
||||
|
||||
|
||||
pPtr = wmalloc(sizeof(ProgressIndicator));
|
||||
memset(pPtr, 0, sizeof(ProgressIndicator));
|
||||
|
||||
|
||||
pPtr->widgetClass = WC_ProgressIndicator;
|
||||
|
||||
|
||||
pPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!pPtr->view) {
|
||||
wfree(pPtr);
|
||||
return NULL;
|
||||
wfree(pPtr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pPtr->view->self = pPtr;
|
||||
|
||||
|
||||
pPtr->view->delegate = &_ProgressIndicatorDelegate;
|
||||
|
||||
|
||||
WMCreateEventHandler(pPtr->view, ExposureMask|StructureNotifyMask,
|
||||
handleEvents, pPtr);
|
||||
|
||||
|
||||
handleEvents, pPtr);
|
||||
|
||||
|
||||
W_ResizeView(pPtr->view, DEFAULT_PROGRESS_INDICATOR_WIDTH,
|
||||
DEFAULT_PROGRESS_INDICATOR_HEIGHT);
|
||||
|
||||
DEFAULT_PROGRESS_INDICATOR_HEIGHT);
|
||||
|
||||
/* Initialize ProgressIndicator Values */
|
||||
pPtr->value = 0;
|
||||
pPtr->minValue = 0;
|
||||
pPtr->maxValue = 100;
|
||||
|
||||
|
||||
return pPtr;
|
||||
}
|
||||
|
||||
@@ -84,13 +84,13 @@ void
|
||||
WMSetProgressIndicatorMinValue(WMProgressIndicator *progressindicator, int value)
|
||||
{
|
||||
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
|
||||
|
||||
|
||||
progressindicator->minValue = value;
|
||||
if (progressindicator->value < value) {
|
||||
progressindicator->value = value;
|
||||
if (progressindicator->view->flags.mapped) {
|
||||
paintProgressIndicator(progressindicator);
|
||||
}
|
||||
progressindicator->value = value;
|
||||
if (progressindicator->view->flags.mapped) {
|
||||
paintProgressIndicator(progressindicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,13 +99,13 @@ void
|
||||
WMSetProgressIndicatorMaxValue(WMProgressIndicator *progressindicator, int value)
|
||||
{
|
||||
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
|
||||
|
||||
|
||||
progressindicator->maxValue = value;
|
||||
if (progressindicator->value > value) {
|
||||
progressindicator->value = value;
|
||||
if (progressindicator->view->flags.mapped) {
|
||||
paintProgressIndicator(progressindicator);
|
||||
}
|
||||
progressindicator->value = value;
|
||||
if (progressindicator->view->flags.mapped) {
|
||||
paintProgressIndicator(progressindicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,19 +114,19 @@ void
|
||||
WMSetProgressIndicatorValue(WMProgressIndicator *progressindicator, int value)
|
||||
{
|
||||
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
|
||||
|
||||
|
||||
progressindicator->value = value;
|
||||
|
||||
|
||||
/* Check if value is within min/max-range */
|
||||
if (progressindicator->minValue > value)
|
||||
progressindicator->value = progressindicator->minValue;
|
||||
|
||||
progressindicator->value = progressindicator->minValue;
|
||||
|
||||
if (progressindicator->maxValue < value)
|
||||
progressindicator->value = progressindicator->maxValue;
|
||||
|
||||
|
||||
progressindicator->value = progressindicator->maxValue;
|
||||
|
||||
|
||||
if (progressindicator->view->flags.mapped) {
|
||||
paintProgressIndicator(progressindicator);
|
||||
paintProgressIndicator(progressindicator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ int
|
||||
WMGetProgressIndicatorMinValue(WMProgressIndicator *progressindicator)
|
||||
{
|
||||
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
|
||||
|
||||
|
||||
return progressindicator->minValue;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ int
|
||||
WMGetProgressIndicatorMaxValue(WMProgressIndicator *progressindicator)
|
||||
{
|
||||
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
|
||||
|
||||
|
||||
return progressindicator->maxValue;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ int
|
||||
WMGetProgressIndicatorValue(WMProgressIndicator *progressindicator)
|
||||
{
|
||||
CHECK_CLASS(progressindicator, WC_ProgressIndicator);
|
||||
|
||||
|
||||
return progressindicator->value;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ didResizeProgressIndicator(W_ViewDelegate *self, WMView *view)
|
||||
WMProgressIndicator *pPtr = (WMProgressIndicator*)view->self;
|
||||
int width = pPtr->view->size.width;
|
||||
int height = pPtr->view->size.height;
|
||||
|
||||
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
}
|
||||
@@ -182,73 +182,73 @@ paintProgressIndicator(ProgressIndicator *pPtr)
|
||||
int perc, w, h;
|
||||
double unit, i;
|
||||
Pixmap buffer;
|
||||
|
||||
|
||||
bgc = WMColorGC(scr->black);
|
||||
wgc = WMColorGC(scr->white);
|
||||
lgc = WMColorGC(scr->gray);
|
||||
dgc = WMColorGC(scr->darkGray);
|
||||
|
||||
|
||||
unit = (double)(size.width - 3.0) / 100;
|
||||
|
||||
buffer = XCreatePixmap(scr->display, pPtr->view->window,
|
||||
size.width, size.height, scr->depth);
|
||||
|
||||
|
||||
buffer = XCreatePixmap(scr->display, pPtr->view->window,
|
||||
size.width, size.height, scr->depth);
|
||||
|
||||
XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width, size.height);
|
||||
|
||||
|
||||
/* Calculate size of Progress to draw and paint ticks*/
|
||||
perc = (pPtr->value - pPtr->minValue) * 100 / (pPtr->maxValue - pPtr->minValue);
|
||||
|
||||
|
||||
w = (int)((double)(perc * unit));
|
||||
h = size.height - 2;
|
||||
|
||||
|
||||
if (w > (size.width - 3))
|
||||
w = size.width - 3;
|
||||
|
||||
w = size.width - 3;
|
||||
|
||||
if (w > 0) {
|
||||
XFillRectangle(scr->display, buffer, lgc, 2, 1, w, h);
|
||||
XFillRectangle(scr->display, buffer, scr->stippleGC, 2, 1, w, h);
|
||||
W_DrawRelief(scr, buffer, 2, 1, w, h, WRFlat);
|
||||
|
||||
/* Draw Progress Marks */
|
||||
i=(5.0*unit);
|
||||
|
||||
XFillRectangle(scr->display, buffer, lgc, 2, 1, w, h);
|
||||
XFillRectangle(scr->display, buffer, scr->stippleGC, 2, 1, w, h);
|
||||
W_DrawRelief(scr, buffer, 2, 1, w, h, WRFlat);
|
||||
|
||||
/* Draw Progress Marks */
|
||||
i=(5.0*unit);
|
||||
|
||||
#ifdef SHOW_PROGRESS_TICKS_ONLY
|
||||
while((int)i<w+5) {
|
||||
while((int)i<w+5) {
|
||||
#else
|
||||
while ((int)i < (size.width - 3)) {
|
||||
while ((int)i < (size.width - 3)) {
|
||||
#endif
|
||||
XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-3);
|
||||
|
||||
i+=(5.0*unit);
|
||||
|
||||
XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-3);
|
||||
|
||||
i+=(5.0*unit);
|
||||
|
||||
#ifdef SHOW_PROGRESS_TICKS_ONLY
|
||||
if((int)i>=w)
|
||||
break;
|
||||
if((int)i>=w)
|
||||
break;
|
||||
#endif
|
||||
|
||||
XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-6);
|
||||
|
||||
i+=(5.0*unit);
|
||||
}
|
||||
|
||||
XDrawLine(scr->display, buffer, dgc, (int)i+2, h-1, i+2, h-6);
|
||||
|
||||
i+=(5.0*unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XDrawLine(scr->display, buffer, bgc, w+2, 1, w+2, h+1);
|
||||
XDrawLine(scr->display, buffer, lgc, 2, h, w+2, h);
|
||||
|
||||
|
||||
|
||||
|
||||
XDrawLine(scr->display, buffer, dgc, 0, 0, 0, size.height-1);
|
||||
XDrawLine(scr->display, buffer, dgc, 0, 0, size.width, 0);
|
||||
XDrawLine(scr->display, buffer, bgc, 1, 1, 1, size.height-1);
|
||||
XDrawLine(scr->display, buffer, bgc, 1, 1, size.width-1, 1);
|
||||
|
||||
|
||||
XDrawLine(scr->display, buffer, wgc, size.width-1, 0,
|
||||
size.width-1, size.height-1);
|
||||
size.width-1, size.height-1);
|
||||
XDrawLine(scr->display, buffer, wgc, 0, size.height-1,
|
||||
size.width-1, size.height-1);
|
||||
|
||||
size.width-1, size.height-1);
|
||||
|
||||
XCopyArea(scr->display, buffer, pPtr->view->window, scr->copyGC, 0, 0,
|
||||
size.width, size.height, 0, 0);
|
||||
|
||||
size.width, size.height, 0, 0);
|
||||
|
||||
XFreePixmap(scr->display, buffer);
|
||||
}
|
||||
|
||||
@@ -257,18 +257,18 @@ static void
|
||||
handleEvents(XEvent *event, void *data)
|
||||
{
|
||||
ProgressIndicator *pPtr = (ProgressIndicator*)data;
|
||||
|
||||
|
||||
CHECK_CLASS(data, WC_ProgressIndicator);
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintProgressIndicator(pPtr);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
destroyProgressIndicator(pPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintProgressIndicator(pPtr);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
destroyProgressIndicator(pPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ static void
|
||||
destroyProgressIndicator(ProgressIndicator *pPtr)
|
||||
{
|
||||
WMRemoveNotificationObserver(pPtr);
|
||||
|
||||
|
||||
wfree(pPtr);
|
||||
}
|
||||
|
||||
+8
-7
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* WINGs WMRuler: nifty ruler widget for WINGs :-)
|
||||
* WINGs WMRuler: nifty ruler widget for WINGs :-)
|
||||
*
|
||||
* Copyright (c) 1999-2000 Nwanua Elumeze
|
||||
*
|
||||
@@ -38,8 +38,8 @@ typedef struct W_Ruler {
|
||||
WMFont *font;
|
||||
WMRulerMargins margins;
|
||||
int offset;
|
||||
int motion; /* the position of the _moving_ marker(s) */
|
||||
int end; /* the last tick on the baseline (restrict markers to it) */
|
||||
int motion; /* the position of the _moving_ marker(s) */
|
||||
int end; /* the last tick on the baseline (restrict markers to it) */
|
||||
|
||||
Pixmap drawBuffer;
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct W_Ruler {
|
||||
|
|
||||
|
||||
*/
|
||||
static void
|
||||
static void
|
||||
drawLeftMarker(Ruler * rPtr)
|
||||
{
|
||||
XPoint points[4];
|
||||
@@ -183,7 +183,7 @@ drawRulerOnPixmap(Ruler * rPtr)
|
||||
|
||||
if (!rPtr->drawBuffer || !rPtr->view->flags.realized)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
XFillRectangle(rPtr->view->screen->display, rPtr->drawBuffer,
|
||||
rPtr->bgGC, 0, 0, rPtr->view->size.width, 40);
|
||||
@@ -346,7 +346,7 @@ handleEvents(XEvent * event, void *data)
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
rulerDidResize(rPtr->view->delegate, rPtr->view);
|
||||
rulerDidResize(rPtr->view->delegate, rPtr->view);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
@@ -500,7 +500,7 @@ WMGetRulerMargins(WMRuler * rPtr)
|
||||
{
|
||||
WMRulerMargins *margins = wmalloc(sizeof(WMRulerMargins));
|
||||
|
||||
if (!rPtr) {
|
||||
if (!rPtr) {
|
||||
margins->first = margins->body = margins->left = 0;
|
||||
margins->right = 100;
|
||||
return margins;
|
||||
@@ -598,3 +598,4 @@ WMGetGrabbedRulerMargin(WMRuler * rPtr)
|
||||
return 0;
|
||||
return rPtr->flags.whichMarker;
|
||||
}
|
||||
|
||||
+425
-425
File diff suppressed because it is too large.
Load diff
+290
-290
@@ -11,20 +11,20 @@ typedef struct W_ScrollView {
|
||||
|
||||
WMView *contentView;
|
||||
WMView *viewport;
|
||||
|
||||
|
||||
WMScroller *vScroller;
|
||||
WMScroller *hScroller;
|
||||
|
||||
|
||||
short lineScroll;
|
||||
short pageScroll;
|
||||
|
||||
|
||||
struct {
|
||||
WMReliefType relief:3;
|
||||
unsigned int hasVScroller:1;
|
||||
unsigned int hasHScroller:1;
|
||||
|
||||
WMReliefType relief:3;
|
||||
unsigned int hasVScroller:1;
|
||||
unsigned int hasHScroller:1;
|
||||
|
||||
} flags;
|
||||
|
||||
|
||||
} ScrollView;
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ static void updateScrollerProportion();
|
||||
|
||||
W_ViewDelegate _ScrollViewViewDelegate = {
|
||||
NULL,
|
||||
NULL,
|
||||
resizeScrollView,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
resizeScrollView,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
WMScrollView*
|
||||
WMCreateScrollView(WMWidget *parent)
|
||||
{
|
||||
@@ -57,29 +57,29 @@ WMCreateScrollView(WMWidget *parent)
|
||||
memset(sPtr, 0, sizeof(ScrollView));
|
||||
|
||||
sPtr->widgetClass = WC_ScrollView;
|
||||
|
||||
|
||||
sPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!sPtr->view) {
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
}
|
||||
sPtr->viewport = W_CreateView(sPtr->view);
|
||||
if (!sPtr->viewport) {
|
||||
W_DestroyView(sPtr->view);
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
W_DestroyView(sPtr->view);
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
}
|
||||
sPtr->view->self = sPtr;
|
||||
sPtr->viewport->self = sPtr;
|
||||
|
||||
|
||||
sPtr->view->delegate = &_ScrollViewViewDelegate;
|
||||
|
||||
sPtr->viewport->flags.mapWhenRealized = 1;
|
||||
|
||||
WMCreateEventHandler(sPtr->view, StructureNotifyMask|ExposureMask,
|
||||
handleEvents, sPtr);
|
||||
WMCreateEventHandler(sPtr->viewport, SubstructureNotifyMask,
|
||||
handleViewportEvents, sPtr);
|
||||
handleEvents, sPtr);
|
||||
WMCreateEventHandler(sPtr->viewport, SubstructureNotifyMask,
|
||||
handleViewportEvents, sPtr);
|
||||
|
||||
sPtr->lineScroll = 4;
|
||||
|
||||
@@ -95,38 +95,38 @@ applyScrollerValues(WMScrollView *sPtr)
|
||||
int x, y;
|
||||
|
||||
if (sPtr->contentView == NULL)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
float v = WMGetScrollerValue(sPtr->hScroller);
|
||||
int size;
|
||||
float v = WMGetScrollerValue(sPtr->hScroller);
|
||||
int size;
|
||||
|
||||
size = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||
|
||||
x = v * size;
|
||||
size = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||
|
||||
x = v * size;
|
||||
} else {
|
||||
x = 0;
|
||||
x = 0;
|
||||
}
|
||||
|
||||
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
float v = WMGetScrollerValue(sPtr->vScroller);
|
||||
float v = WMGetScrollerValue(sPtr->vScroller);
|
||||
|
||||
int size;
|
||||
int size;
|
||||
|
||||
size = sPtr->contentView->size.height-sPtr->viewport->size.height;
|
||||
|
||||
y = v * size;
|
||||
size = sPtr->contentView->size.height-sPtr->viewport->size.height;
|
||||
|
||||
y = v * size;
|
||||
} else {
|
||||
y = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
x = WMAX(0, x);
|
||||
y = WMAX(0, y);
|
||||
|
||||
|
||||
W_MoveView(sPtr->contentView, -x, -y);
|
||||
|
||||
|
||||
W_RaiseView(sPtr->viewport);
|
||||
}
|
||||
|
||||
@@ -137,84 +137,84 @@ reorganizeInterior(WMScrollView *sPtr)
|
||||
int hx, hy, hw;
|
||||
int vx, vy, vh;
|
||||
int cx, cy, cw, ch;
|
||||
|
||||
|
||||
|
||||
|
||||
cw = hw = sPtr->view->size.width;
|
||||
vh = ch = sPtr->view->size.height;
|
||||
|
||||
if (sPtr->flags.relief == WRSimple) {
|
||||
cw -= 2;
|
||||
ch -= 2;
|
||||
cx = 1;
|
||||
cy = 1;
|
||||
cw -= 2;
|
||||
ch -= 2;
|
||||
cx = 1;
|
||||
cy = 1;
|
||||
} else if (sPtr->flags.relief != WRFlat) {
|
||||
cw -= 3;
|
||||
ch -= 3;
|
||||
cx = 2;
|
||||
cy = 2;
|
||||
cw -= 3;
|
||||
ch -= 3;
|
||||
cx = 2;
|
||||
cy = 2;
|
||||
} else {
|
||||
cx = 0;
|
||||
cy = 0;
|
||||
cx = 0;
|
||||
cy = 0;
|
||||
}
|
||||
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
int h = 20;
|
||||
int h = 20;
|
||||
|
||||
ch -= h;
|
||||
ch -= h;
|
||||
|
||||
if (sPtr->flags.relief == WRSimple) {
|
||||
hx = 0;
|
||||
hy = sPtr->view->size.height - h;
|
||||
} else if (sPtr->flags.relief != WRFlat) {
|
||||
hx = 1;
|
||||
hy = sPtr->view->size.height - h - 1;
|
||||
hw -= 2;
|
||||
} else {
|
||||
hx = 0;
|
||||
hy = sPtr->view->size.height - h;
|
||||
}
|
||||
if (sPtr->flags.relief == WRSimple) {
|
||||
hx = 0;
|
||||
hy = sPtr->view->size.height - h;
|
||||
} else if (sPtr->flags.relief != WRFlat) {
|
||||
hx = 1;
|
||||
hy = sPtr->view->size.height - h - 1;
|
||||
hw -= 2;
|
||||
} else {
|
||||
hx = 0;
|
||||
hy = sPtr->view->size.height - h;
|
||||
}
|
||||
} else {
|
||||
/* make compiler shutup */
|
||||
hx = 0;
|
||||
hy = 0;
|
||||
/* make compiler shutup */
|
||||
hx = 0;
|
||||
hy = 0;
|
||||
}
|
||||
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
int w = 20;
|
||||
cw -= w;
|
||||
cx += w;
|
||||
hx += w - 1;
|
||||
hw -= w - 1;
|
||||
|
||||
if (sPtr->flags.relief == WRSimple) {
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
} else if (sPtr->flags.relief != WRFlat) {
|
||||
vx = 1;
|
||||
vy = 1;
|
||||
vh -= 2;
|
||||
} else {
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
}
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
int w = 20;
|
||||
cw -= w;
|
||||
cx += w;
|
||||
hx += w - 1;
|
||||
hw -= w - 1;
|
||||
|
||||
if (sPtr->flags.relief == WRSimple) {
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
} else if (sPtr->flags.relief != WRFlat) {
|
||||
vx = 1;
|
||||
vy = 1;
|
||||
vh -= 2;
|
||||
} else {
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
}
|
||||
} else {
|
||||
/* make compiler shutup */
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
/* make compiler shutup */
|
||||
vx = 0;
|
||||
vy = 0;
|
||||
}
|
||||
|
||||
W_ResizeView(sPtr->viewport, cw, ch);
|
||||
W_MoveView(sPtr->viewport, cx, cy);
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
WMResizeWidget(sPtr->hScroller, hw, 20);
|
||||
WMMoveWidget(sPtr->hScroller, hx, hy);
|
||||
WMResizeWidget(sPtr->hScroller, hw, 20);
|
||||
WMMoveWidget(sPtr->hScroller, hx, hy);
|
||||
}
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
WMResizeWidget(sPtr->vScroller, 20, vh);
|
||||
WMMoveWidget(sPtr->vScroller, vx, vy);
|
||||
WMResizeWidget(sPtr->vScroller, 20, vh);
|
||||
WMMoveWidget(sPtr->vScroller, vx, vy);
|
||||
}
|
||||
|
||||
|
||||
applyScrollerValues(sPtr);
|
||||
}
|
||||
|
||||
@@ -229,8 +229,8 @@ resizeScrollView(W_ViewDelegate *self, WMView *view)
|
||||
|
||||
|
||||
void
|
||||
WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width,
|
||||
unsigned int height)
|
||||
WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
int w, h, x;
|
||||
|
||||
@@ -239,23 +239,23 @@ WMResizeScrollViewContent(WMScrollView *sPtr, unsigned int width,
|
||||
|
||||
x = 0;
|
||||
if (sPtr->flags.relief == WRSimple) {
|
||||
w += 2;
|
||||
h += 2;
|
||||
w += 2;
|
||||
h += 2;
|
||||
} else if (sPtr->flags.relief != WRFlat) {
|
||||
w += 4;
|
||||
h += 4;
|
||||
x = 1;
|
||||
w += 4;
|
||||
h += 4;
|
||||
x = 1;
|
||||
}
|
||||
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
WMResizeWidget(sPtr->vScroller, 20, h);
|
||||
width -= W_VIEW(sPtr->vScroller)->size.width;
|
||||
WMResizeWidget(sPtr->vScroller, 20, h);
|
||||
width -= W_VIEW(sPtr->vScroller)->size.width;
|
||||
}
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
WMResizeWidget(sPtr->hScroller, w, 20);
|
||||
WMMoveWidget(sPtr->hScroller, x, h);
|
||||
height -= W_VIEW(sPtr->hScroller)->size.height;
|
||||
WMResizeWidget(sPtr->hScroller, w, 20);
|
||||
WMMoveWidget(sPtr->hScroller, x, h);
|
||||
height -= W_VIEW(sPtr->hScroller)->size.height;
|
||||
}
|
||||
|
||||
W_ResizeView(sPtr->view, w, h);
|
||||
@@ -268,7 +268,7 @@ void
|
||||
WMSetScrollViewLineScroll(WMScrollView *sPtr, int amount)
|
||||
{
|
||||
assert(amount > 0);
|
||||
|
||||
|
||||
sPtr->lineScroll = amount;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ WMSetScrollViewPageScroll(WMScrollView *sPtr, int amount)
|
||||
}
|
||||
|
||||
|
||||
WMRect
|
||||
WMRect
|
||||
WMGetScrollViewVisibleRect(WMScrollView *sPtr)
|
||||
{
|
||||
WMRect rect;
|
||||
@@ -300,20 +300,20 @@ 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));
|
||||
WMSetScrollerParameters(sPtr->hScroller, xpos,
|
||||
WMGetScrollerKnobProportion(sPtr->hScroller));
|
||||
if (sPtr->vScroller)
|
||||
WMSetScrollerParameters(sPtr->vScroller, ypos,
|
||||
WMGetScrollerKnobProportion(sPtr->vScroller));
|
||||
|
||||
WMSetScrollerParameters(sPtr->vScroller, ypos,
|
||||
WMGetScrollerKnobProportion(sPtr->vScroller));
|
||||
|
||||
W_MoveView(sPtr->contentView, -point.x, -point.y);
|
||||
}
|
||||
|
||||
@@ -326,99 +326,99 @@ doScrolling(WMWidget *self, void *data)
|
||||
int pos;
|
||||
int vpsize;
|
||||
float size;
|
||||
|
||||
|
||||
if (sPtr->hScroller == (WMScroller *)self) {
|
||||
pos = -sPtr->contentView->pos.x;
|
||||
size = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||
vpsize = sPtr->viewport->size.width - sPtr->pageScroll;
|
||||
pos = -sPtr->contentView->pos.x;
|
||||
size = sPtr->contentView->size.width-sPtr->viewport->size.width;
|
||||
vpsize = sPtr->viewport->size.width - sPtr->pageScroll;
|
||||
} else {
|
||||
pos = -sPtr->contentView->pos.y;
|
||||
size = sPtr->contentView->size.height-sPtr->viewport->size.height;
|
||||
vpsize = sPtr->viewport->size.height - sPtr->pageScroll;
|
||||
pos = -sPtr->contentView->pos.y;
|
||||
size = sPtr->contentView->size.height-sPtr->viewport->size.height;
|
||||
vpsize = sPtr->viewport->size.height - sPtr->pageScroll;
|
||||
}
|
||||
if (vpsize <= 0)
|
||||
vpsize = 1;
|
||||
vpsize = 1;
|
||||
|
||||
switch (WMGetScrollerHitPart(self)) {
|
||||
case WSDecrementLine:
|
||||
if (pos > 0) {
|
||||
pos-=sPtr->lineScroll;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
if (pos > 0) {
|
||||
pos-=sPtr->lineScroll;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
case WSIncrementLine:
|
||||
if (pos < size) {
|
||||
pos+=sPtr->lineScroll;
|
||||
if (pos > size)
|
||||
pos = size;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
if (pos < size) {
|
||||
pos+=sPtr->lineScroll;
|
||||
if (pos > size)
|
||||
pos = size;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
|
||||
case WSKnob:
|
||||
value = WMGetScrollerValue(self);
|
||||
pos = value*size;
|
||||
break;
|
||||
value = WMGetScrollerValue(self);
|
||||
pos = value*size;
|
||||
break;
|
||||
|
||||
case WSDecrementPage:
|
||||
if (pos > 0) {
|
||||
pos -= vpsize;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
if (pos > 0) {
|
||||
pos -= vpsize;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
|
||||
case WSDecrementWheel:
|
||||
if (pos > 0) {
|
||||
pos -= vpsize/3;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
if (pos > 0) {
|
||||
pos -= vpsize/3;
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
|
||||
case WSIncrementPage:
|
||||
if (pos < size) {
|
||||
pos += vpsize;
|
||||
if (pos > size)
|
||||
pos = size;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
if (pos < size) {
|
||||
pos += vpsize;
|
||||
if (pos > size)
|
||||
pos = size;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
|
||||
case WSIncrementWheel:
|
||||
if (pos < size) {
|
||||
pos += vpsize/3;
|
||||
if (pos > size)
|
||||
pos = size;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
if (pos < size) {
|
||||
pos += vpsize/3;
|
||||
if (pos > size)
|
||||
pos = size;
|
||||
value = (float)pos / size;
|
||||
WMSetScrollerParameters(self, value,
|
||||
WMGetScrollerKnobProportion(self));
|
||||
}
|
||||
break;
|
||||
|
||||
case WSNoPart:
|
||||
case WSKnobSlot:
|
||||
break;
|
||||
case WSNoPart:
|
||||
case WSKnobSlot:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (sPtr->hScroller == (WMScroller *)self) {
|
||||
W_MoveView(sPtr->contentView, -pos, sPtr->contentView->pos.y);
|
||||
W_MoveView(sPtr->contentView, -pos, sPtr->contentView->pos.y);
|
||||
} else {
|
||||
W_MoveView(sPtr->contentView, sPtr->contentView->pos.x, -pos);
|
||||
W_MoveView(sPtr->contentView, sPtr->contentView->pos.x, -pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,32 +442,32 @@ void
|
||||
WMSetScrollViewHasHorizontalScroller(WMScrollView *sPtr, Bool flag)
|
||||
{
|
||||
if (flag) {
|
||||
if (sPtr->flags.hasHScroller)
|
||||
return;
|
||||
sPtr->flags.hasHScroller = 1;
|
||||
|
||||
sPtr->hScroller = WMCreateScroller(sPtr);
|
||||
WMSetScrollerAction(sPtr->hScroller, doScrolling, sPtr);
|
||||
/* make it a horiz. scroller */
|
||||
WMResizeWidget(sPtr->hScroller, 2, 1);
|
||||
if (sPtr->flags.hasHScroller)
|
||||
return;
|
||||
sPtr->flags.hasHScroller = 1;
|
||||
|
||||
if (W_VIEW_REALIZED(sPtr->view)) {
|
||||
WMRealizeWidget(sPtr->hScroller);
|
||||
}
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
sPtr->hScroller = WMCreateScroller(sPtr);
|
||||
WMSetScrollerAction(sPtr->hScroller, doScrolling, sPtr);
|
||||
/* make it a horiz. scroller */
|
||||
WMResizeWidget(sPtr->hScroller, 2, 1);
|
||||
|
||||
WMMapWidget(sPtr->hScroller);
|
||||
if (W_VIEW_REALIZED(sPtr->view)) {
|
||||
WMRealizeWidget(sPtr->hScroller);
|
||||
}
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
|
||||
WMMapWidget(sPtr->hScroller);
|
||||
} else {
|
||||
if (!sPtr->flags.hasHScroller)
|
||||
return;
|
||||
|
||||
WMUnmapWidget(sPtr->hScroller);
|
||||
WMDestroyWidget(sPtr->hScroller);
|
||||
sPtr->hScroller = NULL;
|
||||
sPtr->flags.hasHScroller = 0;
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
if (!sPtr->flags.hasHScroller)
|
||||
return;
|
||||
|
||||
WMUnmapWidget(sPtr->hScroller);
|
||||
WMDestroyWidget(sPtr->hScroller);
|
||||
sPtr->hScroller = NULL;
|
||||
sPtr->flags.hasHScroller = 0;
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,33 +476,33 @@ void
|
||||
WMSetScrollViewHasVerticalScroller(WMScrollView *sPtr, Bool flag)
|
||||
{
|
||||
if (flag) {
|
||||
if (sPtr->flags.hasVScroller)
|
||||
return;
|
||||
sPtr->flags.hasVScroller = 1;
|
||||
|
||||
sPtr->vScroller = WMCreateScroller(sPtr);
|
||||
WMSetScrollerAction(sPtr->vScroller, doScrolling, sPtr);
|
||||
WMSetScrollerArrowsPosition(sPtr->vScroller, WSAMaxEnd);
|
||||
/* make it a vert. scroller */
|
||||
WMResizeWidget(sPtr->vScroller, 1, 2);
|
||||
if (sPtr->flags.hasVScroller)
|
||||
return;
|
||||
sPtr->flags.hasVScroller = 1;
|
||||
|
||||
if (W_VIEW_REALIZED(sPtr->view)) {
|
||||
WMRealizeWidget(sPtr->vScroller);
|
||||
}
|
||||
sPtr->vScroller = WMCreateScroller(sPtr);
|
||||
WMSetScrollerAction(sPtr->vScroller, doScrolling, sPtr);
|
||||
WMSetScrollerArrowsPosition(sPtr->vScroller, WSAMaxEnd);
|
||||
/* make it a vert. scroller */
|
||||
WMResizeWidget(sPtr->vScroller, 1, 2);
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
|
||||
WMMapWidget(sPtr->vScroller);
|
||||
if (W_VIEW_REALIZED(sPtr->view)) {
|
||||
WMRealizeWidget(sPtr->vScroller);
|
||||
}
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
|
||||
WMMapWidget(sPtr->vScroller);
|
||||
} else {
|
||||
if (!sPtr->flags.hasVScroller)
|
||||
return;
|
||||
sPtr->flags.hasVScroller = 0;
|
||||
|
||||
WMUnmapWidget(sPtr->vScroller);
|
||||
WMDestroyWidget(sPtr->vScroller);
|
||||
sPtr->vScroller = NULL;
|
||||
if (!sPtr->flags.hasVScroller)
|
||||
return;
|
||||
sPtr->flags.hasVScroller = 0;
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
WMUnmapWidget(sPtr->vScroller);
|
||||
WMDestroyWidget(sPtr->vScroller);
|
||||
sPtr->vScroller = NULL;
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,23 +511,23 @@ void
|
||||
WMSetScrollViewContentView(WMScrollView *sPtr, WMView *view)
|
||||
{
|
||||
assert(sPtr->contentView == NULL);
|
||||
|
||||
|
||||
sPtr->contentView = view;
|
||||
|
||||
W_ReparentView(sPtr->contentView, sPtr->viewport, 0, 0);
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
float prop;
|
||||
|
||||
prop = (float)sPtr->viewport->size.width/sPtr->contentView->size.width;
|
||||
WMSetScrollerParameters(sPtr->hScroller, 0, prop);
|
||||
float prop;
|
||||
|
||||
prop = (float)sPtr->viewport->size.width/sPtr->contentView->size.width;
|
||||
WMSetScrollerParameters(sPtr->hScroller, 0, prop);
|
||||
}
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
float prop;
|
||||
|
||||
prop = (float)sPtr->viewport->size.height/sPtr->contentView->size.height;
|
||||
|
||||
WMSetScrollerParameters(sPtr->vScroller, 0, prop);
|
||||
float prop;
|
||||
|
||||
prop = (float)sPtr->viewport->size.height/sPtr->contentView->size.height;
|
||||
|
||||
WMSetScrollerParameters(sPtr->vScroller, 0, prop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,13 +536,13 @@ void
|
||||
WMSetScrollViewRelief(WMScrollView *sPtr, WMReliefType type)
|
||||
{
|
||||
sPtr->flags.relief = type;
|
||||
|
||||
|
||||
reorganizeInterior(sPtr);
|
||||
|
||||
|
||||
if (sPtr->view->flags.mapped)
|
||||
paintScrollView(sPtr);
|
||||
|
||||
|
||||
paintScrollView(sPtr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -551,8 +551,8 @@ static void
|
||||
paintScrollView(ScrollView *sPtr)
|
||||
{
|
||||
W_DrawRelief(sPtr->view->screen, sPtr->view->window, 0, 0,
|
||||
sPtr->view->size.width, sPtr->view->size.height,
|
||||
sPtr->flags.relief);
|
||||
sPtr->view->size.width, sPtr->view->size.height,
|
||||
sPtr->flags.relief);
|
||||
}
|
||||
|
||||
|
||||
@@ -562,29 +562,29 @@ updateScrollerProportion(ScrollView *sPtr)
|
||||
float prop, value;
|
||||
float oldV, oldP;
|
||||
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
oldV = WMGetScrollerValue(sPtr->hScroller);
|
||||
oldP = WMGetScrollerKnobProportion(sPtr->hScroller);
|
||||
|
||||
prop = (float)sPtr->viewport->size.width/(float)sPtr->contentView->size.width;
|
||||
|
||||
if (oldP == 1.0)
|
||||
value = 0;
|
||||
else
|
||||
value = (prop * oldV) / oldP;
|
||||
WMSetScrollerParameters(sPtr->hScroller, value, prop);
|
||||
if (sPtr->flags.hasHScroller) {
|
||||
oldV = WMGetScrollerValue(sPtr->hScroller);
|
||||
oldP = WMGetScrollerKnobProportion(sPtr->hScroller);
|
||||
|
||||
prop = (float)sPtr->viewport->size.width/(float)sPtr->contentView->size.width;
|
||||
|
||||
if (oldP == 1.0)
|
||||
value = 0;
|
||||
else
|
||||
value = (prop * oldV) / oldP;
|
||||
WMSetScrollerParameters(sPtr->hScroller, value, prop);
|
||||
}
|
||||
if (sPtr->flags.hasVScroller) {
|
||||
oldV = WMGetScrollerValue(sPtr->vScroller);
|
||||
oldP = WMGetScrollerKnobProportion(sPtr->vScroller);
|
||||
|
||||
prop = (float)sPtr->viewport->size.height/(float)sPtr->contentView->size.height;
|
||||
oldV = WMGetScrollerValue(sPtr->vScroller);
|
||||
oldP = WMGetScrollerKnobProportion(sPtr->vScroller);
|
||||
|
||||
if (oldP == 1.0)
|
||||
value = 0;
|
||||
else
|
||||
value = (prop * oldV) / oldP;
|
||||
WMSetScrollerParameters(sPtr->vScroller, value, prop);
|
||||
prop = (float)sPtr->viewport->size.height/(float)sPtr->contentView->size.height;
|
||||
|
||||
if (oldP == 1.0)
|
||||
value = 0;
|
||||
else
|
||||
value = (prop * oldV) / oldP;
|
||||
WMSetScrollerParameters(sPtr->vScroller, value, prop);
|
||||
}
|
||||
applyScrollerValues(sPtr);
|
||||
}
|
||||
@@ -595,9 +595,9 @@ handleViewportEvents(XEvent *event, void *data)
|
||||
{
|
||||
ScrollView *sPtr = (ScrollView*)data;
|
||||
|
||||
if (sPtr->contentView
|
||||
&& event->xconfigure.window == sPtr->contentView->window)
|
||||
updateScrollerProportion(sPtr);
|
||||
if (sPtr->contentView
|
||||
&& event->xconfigure.window == sPtr->contentView->window)
|
||||
updateScrollerProportion(sPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -608,27 +608,27 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
CHECK_CLASS(data, WC_ScrollView);
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
if (event->xexpose.serial == 0) /* means it's artificial */
|
||||
W_RedisplayView(sPtr->contentView);
|
||||
else
|
||||
paintScrollView(sPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyScrollView(sPtr);
|
||||
break;
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
if (event->xexpose.serial == 0) /* means it's artificial */
|
||||
W_RedisplayView(sPtr->contentView);
|
||||
else
|
||||
paintScrollView(sPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyScrollView(sPtr);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
destroyScrollView(ScrollView *sPtr)
|
||||
{
|
||||
{
|
||||
wfree(sPtr);
|
||||
}
|
||||
|
||||
+213
-213
@@ -14,7 +14,7 @@ typedef struct W_Slider {
|
||||
|
||||
int minValue;
|
||||
int maxValue;
|
||||
|
||||
|
||||
int value;
|
||||
|
||||
Pixmap knobPixmap;
|
||||
@@ -26,12 +26,12 @@ typedef struct W_Slider {
|
||||
int knobThickness;
|
||||
|
||||
struct {
|
||||
unsigned int continuous:1;
|
||||
|
||||
unsigned int vertical:1;
|
||||
unsigned int dragging:1;
|
||||
unsigned int continuous:1;
|
||||
|
||||
unsigned int vertical:1;
|
||||
unsigned int dragging:1;
|
||||
} flags;
|
||||
|
||||
|
||||
} Slider;
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ static void didResizeSlider();
|
||||
|
||||
W_ViewDelegate _SliderViewDelegate = {
|
||||
NULL,
|
||||
NULL,
|
||||
didResizeSlider,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
didResizeSlider,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -75,23 +75,23 @@ WMCreateSlider(WMWidget *parent)
|
||||
memset(sPtr, 0, sizeof(Slider));
|
||||
|
||||
sPtr->widgetClass = WC_Slider;
|
||||
|
||||
|
||||
sPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!sPtr->view) {
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
}
|
||||
sPtr->view->self = sPtr;
|
||||
|
||||
sPtr->view->delegate = &_SliderViewDelegate;
|
||||
|
||||
WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask,
|
||||
handleEvents, sPtr);
|
||||
handleEvents, sPtr);
|
||||
|
||||
|
||||
WMCreateEventHandler(sPtr->view, ButtonPressMask|ButtonReleaseMask
|
||||
|EnterWindowMask|LeaveWindowMask|ButtonMotionMask,
|
||||
handleActionEvents, sPtr);
|
||||
|EnterWindowMask|LeaveWindowMask|ButtonMotionMask,
|
||||
handleActionEvents, sPtr);
|
||||
|
||||
W_ResizeView(sPtr->view, 100, 16);
|
||||
sPtr->flags.vertical = 0;
|
||||
@@ -104,7 +104,7 @@ WMCreateSlider(WMWidget *parent)
|
||||
sPtr->flags.continuous = 1;
|
||||
|
||||
WMAddNotificationObserver(realizeObserver, sPtr,
|
||||
WMViewRealizedNotification, sPtr->view);
|
||||
WMViewRealizedNotification, sPtr->view);
|
||||
|
||||
return sPtr;
|
||||
}
|
||||
@@ -114,12 +114,12 @@ void
|
||||
WMSetSliderImage(WMSlider *sPtr, WMPixmap *pixmap)
|
||||
{
|
||||
if (sPtr->backPixmap)
|
||||
WMReleasePixmap(sPtr->backPixmap);
|
||||
WMReleasePixmap(sPtr->backPixmap);
|
||||
|
||||
sPtr->backPixmap = WMRetainPixmap(pixmap);
|
||||
|
||||
|
||||
if (sPtr->view->flags.mapped) {
|
||||
paintSlider(sPtr);
|
||||
paintSlider(sPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +132,11 @@ WMSetSliderKnobThickness(WMSlider *sPtr, int thickness)
|
||||
sPtr->knobThickness = thickness;
|
||||
|
||||
if (sPtr->knobPixmap) {
|
||||
makeKnobPixmap(sPtr);
|
||||
makeKnobPixmap(sPtr);
|
||||
}
|
||||
|
||||
if (sPtr->view->flags.mapped) {
|
||||
paintSlider(sPtr);
|
||||
paintSlider(sPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ int
|
||||
WMGetSliderMinValue(WMSlider *slider)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
return slider->minValue;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ int
|
||||
WMGetSliderMaxValue(WMSlider *slider)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
return slider->maxValue;
|
||||
}
|
||||
|
||||
@@ -172,12 +172,12 @@ void
|
||||
WMSetSliderMinValue(WMSlider *slider, int value)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
slider->minValue = value;
|
||||
if (slider->value < value) {
|
||||
slider->value = value;
|
||||
if (slider->view->flags.mapped)
|
||||
paintSlider(slider);
|
||||
slider->value = value;
|
||||
if (slider->view->flags.mapped)
|
||||
paintSlider(slider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,12 +186,12 @@ void
|
||||
WMSetSliderMaxValue(WMSlider *slider, int value)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
slider->maxValue = value;
|
||||
if (slider->value > value) {
|
||||
slider->value = value;
|
||||
if (slider->view->flags.mapped)
|
||||
paintSlider(slider);
|
||||
slider->value = value;
|
||||
if (slider->view->flags.mapped)
|
||||
paintSlider(slider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,16 +200,16 @@ void
|
||||
WMSetSliderValue(WMSlider *slider, int value)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
if (value < slider->minValue)
|
||||
slider->value = slider->minValue;
|
||||
slider->value = slider->minValue;
|
||||
else if (value > slider->maxValue)
|
||||
slider->value = slider->maxValue;
|
||||
slider->value = slider->maxValue;
|
||||
else
|
||||
slider->value = value;
|
||||
|
||||
slider->value = value;
|
||||
|
||||
if (slider->view->flags.mapped)
|
||||
paintSlider(slider);
|
||||
paintSlider(slider);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ void
|
||||
WMSetSliderContinuous(WMSlider *slider, Bool flag)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
slider->flags.continuous = ((flag==0) ? 0 : 1);
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ void
|
||||
WMSetSliderAction(WMSlider *slider, WMAction *action, void *data)
|
||||
{
|
||||
CHECK_CLASS(slider, WC_Slider);
|
||||
|
||||
|
||||
slider->action = action;
|
||||
slider->clientData = data;
|
||||
}
|
||||
@@ -238,57 +238,57 @@ makeKnobPixmap(Slider *sPtr)
|
||||
Pixmap pix;
|
||||
WMScreen *scr = sPtr->view->screen;
|
||||
int w, h;
|
||||
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
w = sPtr->view->size.width-2;
|
||||
h = sPtr->knobThickness;
|
||||
w = sPtr->view->size.width-2;
|
||||
h = sPtr->knobThickness;
|
||||
} else {
|
||||
w = sPtr->knobThickness;
|
||||
h = sPtr->view->size.height-2;
|
||||
w = sPtr->knobThickness;
|
||||
h = sPtr->view->size.height-2;
|
||||
}
|
||||
|
||||
|
||||
pix = XCreatePixmap(scr->display, sPtr->view->window, w, h, scr->depth);
|
||||
XFillRectangle(scr->display, pix, WMColorGC(scr->gray), 0, 0, w, h);
|
||||
|
||||
if (sPtr->knobThickness < 10) {
|
||||
W_DrawRelief(scr, pix, 0, 0, w, h, WRRaised);
|
||||
W_DrawRelief(scr, pix, 0, 0, w, h, WRRaised);
|
||||
} else if (sPtr->flags.vertical) {
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, 1, w-2, h/2-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, h/2, w-2, h-2);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-2, 0);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h/2-2, w-3, h/2-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, h/2-1, w-3, h/2-1);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), w-1, 0, w-1, h-2);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-3, w-2, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-2, w-1, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-1, w-1,h-1);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, 1, w-2, h/2-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-2, h/2, w-2, h-2);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-2, 0);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h/2-2, w-3, h/2-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, h/2-1, w-3, h/2-1);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), w-1, 0, w-1, h-2);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-3, w-2, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-2, w-1, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 0, h-1, w-1,h-1);
|
||||
} else {
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-3, 0);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, w-3, 0);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2-2, 1, w/2-2, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), w/2-1, 0, w/2-1, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 0, 0, 0, h-2);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-3, 0, w-3, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), w-2, 0, w-2, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-1, 0, w-1, h-1);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), 1, 0, 1, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2-2, 1, w/2-2, h-3);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->white), w/2-1, 0, w/2-1, h-3);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), 1, h-1, w/2+1, h-1);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h-2, w/2-2, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2, h-2, w-3,h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-3, 0, w-3, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), w-2, 0, w-2, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w-1, 0, w-1, h-1);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-1, w-2, h-1);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), 1, h-1, w/2+1, h-1);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), 1, h-2, w/2-2, h-2);
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->darkGray), w/2, h-2, w-3,h-2);
|
||||
|
||||
XDrawLine(scr->display, pix, WMColorGC(scr->black), 0, h-1, w-2, h-1);
|
||||
}
|
||||
|
||||
|
||||
if (sPtr->knobPixmap)
|
||||
XFreePixmap(scr->display, sPtr->knobPixmap);
|
||||
XFreePixmap(scr->display, sPtr->knobPixmap);
|
||||
sPtr->knobPixmap = pix;
|
||||
}
|
||||
|
||||
@@ -302,19 +302,19 @@ didResizeSlider(W_ViewDelegate *self, WMView *view)
|
||||
|
||||
assert(width > 0);
|
||||
assert(height > 0);
|
||||
|
||||
|
||||
if (width > height) {
|
||||
if (sPtr->flags.vertical) {
|
||||
sPtr->flags.vertical = 0;
|
||||
if (sPtr->view->flags.realized)
|
||||
makeKnobPixmap(sPtr);
|
||||
}
|
||||
if (sPtr->flags.vertical) {
|
||||
sPtr->flags.vertical = 0;
|
||||
if (sPtr->view->flags.realized)
|
||||
makeKnobPixmap(sPtr);
|
||||
}
|
||||
} else {
|
||||
if (!sPtr->flags.vertical) {
|
||||
sPtr->flags.vertical = 1;
|
||||
if (sPtr->view->flags.realized)
|
||||
makeKnobPixmap(sPtr);
|
||||
}
|
||||
if (!sPtr->flags.vertical) {
|
||||
sPtr->flags.vertical = 1;
|
||||
if (sPtr->view->flags.realized)
|
||||
makeKnobPixmap(sPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,53 +330,53 @@ paintSlider(Slider *sPtr)
|
||||
WMSize size = sPtr->view->size;
|
||||
int pos;
|
||||
Pixmap buffer;
|
||||
|
||||
|
||||
#define MINV sPtr->minValue
|
||||
#define MAXV sPtr->maxValue
|
||||
#define POSV sPtr->value
|
||||
|
||||
|
||||
bgc = WMColorGC(scr->black);
|
||||
wgc = WMColorGC(scr->white);
|
||||
lgc = WMColorGC(scr->gray);
|
||||
|
||||
buffer = XCreatePixmap(scr->display, sPtr->view->window,
|
||||
size.width, size.height, scr->depth);
|
||||
buffer = XCreatePixmap(scr->display, sPtr->view->window,
|
||||
size.width, size.height, scr->depth);
|
||||
|
||||
if (sPtr->backPixmap) {
|
||||
WMSize size = WMGetPixmapSize(sPtr->backPixmap);
|
||||
WMSize size = WMGetPixmapSize(sPtr->backPixmap);
|
||||
|
||||
XCopyArea(scr->display, WMGetPixmapXID(sPtr->backPixmap),
|
||||
buffer, scr->copyGC, 0, 0, size.width, size.height, 1, 1);
|
||||
XCopyArea(scr->display, WMGetPixmapXID(sPtr->backPixmap),
|
||||
buffer, scr->copyGC, 0, 0, size.width, size.height, 1, 1);
|
||||
} else {
|
||||
XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width,
|
||||
size.height);
|
||||
XFillRectangle(scr->display, buffer, scr->stippleGC, 0, 0, size.width,
|
||||
size.height);
|
||||
XFillRectangle(scr->display, buffer, lgc, 0, 0, size.width,
|
||||
size.height);
|
||||
XFillRectangle(scr->display, buffer, scr->stippleGC, 0, 0, size.width,
|
||||
size.height);
|
||||
}
|
||||
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1;
|
||||
/* draw knob */
|
||||
XCopyArea(scr->display, sPtr->knobPixmap, buffer,
|
||||
scr->copyGC, 0, 0, size.width-2, sPtr->knobThickness,
|
||||
1, pos);
|
||||
pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1;
|
||||
/* draw knob */
|
||||
XCopyArea(scr->display, sPtr->knobPixmap, buffer,
|
||||
scr->copyGC, 0, 0, size.width-2, sPtr->knobThickness,
|
||||
1, pos);
|
||||
} else {
|
||||
pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1;
|
||||
/* draw knob */
|
||||
XCopyArea(scr->display, sPtr->knobPixmap, buffer,
|
||||
scr->copyGC, 0, 0, sPtr->knobThickness, size.height, pos, 1);
|
||||
pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV)+1;
|
||||
/* draw knob */
|
||||
XCopyArea(scr->display, sPtr->knobPixmap, buffer,
|
||||
scr->copyGC, 0, 0, sPtr->knobThickness, size.height, pos, 1);
|
||||
}
|
||||
|
||||
XDrawLine(scr->display, buffer, bgc, 0, 0, 0, size.height-1);
|
||||
XDrawLine(scr->display, buffer, bgc, 0, 0, size.width, 0);
|
||||
|
||||
XDrawLine(scr->display, buffer, wgc, size.width-1, 0,
|
||||
size.width-1, size.height-1);
|
||||
XDrawLine(scr->display, buffer, wgc, 0, size.height-1,
|
||||
size.width-1, size.height-1);
|
||||
|
||||
XDrawLine(scr->display, buffer, wgc, size.width-1, 0,
|
||||
size.width-1, size.height-1);
|
||||
XDrawLine(scr->display, buffer, wgc, 0, size.height-1,
|
||||
size.width-1, size.height-1);
|
||||
|
||||
XCopyArea(scr->display, buffer, sPtr->view->window, scr->copyGC, 0, 0,
|
||||
size.width, size.height, 0, 0);
|
||||
size.width, size.height, 0, 0);
|
||||
XFreePixmap(scr->display, buffer);
|
||||
}
|
||||
|
||||
@@ -391,16 +391,16 @@ handleEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintSlider(sPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroySlider(sPtr);
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintSlider(sPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroySlider(sPtr);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,24 +415,24 @@ getSliderPart(Slider *sPtr, int x, int y)
|
||||
int p;
|
||||
int pos;
|
||||
WMSize size = sPtr->view->size;
|
||||
|
||||
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
p = y;
|
||||
pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV);
|
||||
if (p < pos)
|
||||
return INCR_PART;
|
||||
if (p > pos + sPtr->knobThickness)
|
||||
return DECR_PART;
|
||||
return KNOB_PART;
|
||||
p = y;
|
||||
pos = (size.height-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV);
|
||||
if (p < pos)
|
||||
return INCR_PART;
|
||||
if (p > pos + sPtr->knobThickness)
|
||||
return DECR_PART;
|
||||
return KNOB_PART;
|
||||
} else {
|
||||
p = x;
|
||||
pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV);
|
||||
if (p < pos)
|
||||
return DECR_PART;
|
||||
if (p > pos + sPtr->knobThickness)
|
||||
return INCR_PART;
|
||||
return KNOB_PART;
|
||||
p = x;
|
||||
pos = (size.width-2-sPtr->knobThickness)*(POSV-MINV)/(MAXV-MINV);
|
||||
if (p < pos)
|
||||
return DECR_PART;
|
||||
if (p > pos + sPtr->knobThickness)
|
||||
return INCR_PART;
|
||||
return KNOB_PART;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,18 +444,18 @@ valueForMousePoint(Slider *sPtr, int x, int y)
|
||||
int f;
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
f = (y-sPtr->knobThickness/2)*(MAXV-MINV)
|
||||
/ ((int)size.height-2-sPtr->knobThickness);
|
||||
f = (y-sPtr->knobThickness/2)*(MAXV-MINV)
|
||||
/ ((int)size.height-2-sPtr->knobThickness);
|
||||
} else {
|
||||
f = (x-sPtr->knobThickness/2)*(MAXV-MINV)
|
||||
/ ((int)size.width-2-sPtr->knobThickness);
|
||||
f = (x-sPtr->knobThickness/2)*(MAXV-MINV)
|
||||
/ ((int)size.width-2-sPtr->knobThickness);
|
||||
}
|
||||
|
||||
f += sPtr->minValue;
|
||||
if (f < sPtr->minValue)
|
||||
f = sPtr->minValue;
|
||||
f = sPtr->minValue;
|
||||
else if (f > sPtr->maxValue)
|
||||
f = sPtr->maxValue;
|
||||
f = sPtr->maxValue;
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -470,81 +470,81 @@ handleActionEvents(XEvent *event, void *data)
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button==WINGsConfiguration.mouseWheelUp
|
||||
&&!sPtr->flags.dragging) {
|
||||
/* Wheel up */
|
||||
if (sPtr->value+1<=sPtr->maxValue) {
|
||||
WMSetSliderValue(sPtr, sPtr->value+1);
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
} else if (event->xbutton.button==WINGsConfiguration.mouseWheelDown
|
||||
&&!sPtr->flags.dragging) {
|
||||
/* Wheel down */
|
||||
if (sPtr->value-1>=sPtr->minValue)
|
||||
{
|
||||
WMSetSliderValue(sPtr, sPtr->value-1);
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (getSliderPart(sPtr, event->xbutton.x, event->xbutton.y)
|
||||
==KNOB_PART)
|
||||
sPtr->flags.dragging = 1;
|
||||
else {
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button==WINGsConfiguration.mouseWheelUp
|
||||
&&!sPtr->flags.dragging) {
|
||||
/* Wheel up */
|
||||
if (sPtr->value+1<=sPtr->maxValue) {
|
||||
WMSetSliderValue(sPtr, sPtr->value+1);
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
} else if (event->xbutton.button==WINGsConfiguration.mouseWheelDown
|
||||
&&!sPtr->flags.dragging) {
|
||||
/* Wheel down */
|
||||
if (sPtr->value-1>=sPtr->minValue)
|
||||
{
|
||||
WMSetSliderValue(sPtr, sPtr->value-1);
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (getSliderPart(sPtr, event->xbutton.x, event->xbutton.y)
|
||||
==KNOB_PART)
|
||||
sPtr->flags.dragging = 1;
|
||||
else {
|
||||
#ifdef STRICT_NEXT_BEHAVIOUR
|
||||
sPtr->flags.dragging = 1;
|
||||
sPtr->flags.dragging = 1;
|
||||
|
||||
sPtr->value = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
paintSlider(sPtr);
|
||||
sPtr->value = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
paintSlider(sPtr);
|
||||
#else
|
||||
int tmp;
|
||||
int tmp;
|
||||
|
||||
if (event->xbutton.button == Button2) {
|
||||
sPtr->flags.dragging = 1;
|
||||
if (event->xbutton.button == Button2) {
|
||||
sPtr->flags.dragging = 1;
|
||||
|
||||
sPtr->value = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
paintSlider(sPtr);
|
||||
} else {
|
||||
tmp = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
if (tmp < sPtr->value)
|
||||
tmp = sPtr->value-1;
|
||||
else
|
||||
tmp = sPtr->value+1;
|
||||
WMSetSliderValue(sPtr, tmp);
|
||||
}
|
||||
sPtr->value = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
paintSlider(sPtr);
|
||||
} else {
|
||||
tmp = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
if (tmp < sPtr->value)
|
||||
tmp = sPtr->value-1;
|
||||
else
|
||||
tmp = sPtr->value+1;
|
||||
WMSetSliderValue(sPtr, tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (!sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
sPtr->flags.dragging = 0;
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (!sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
sPtr->flags.dragging = 0;
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (sPtr->flags.dragging) {
|
||||
sPtr->value = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
paintSlider(sPtr);
|
||||
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionNotify:
|
||||
if (sPtr->flags.dragging) {
|
||||
sPtr->value = valueForMousePoint(sPtr, event->xmotion.x,
|
||||
event->xmotion.y);
|
||||
paintSlider(sPtr);
|
||||
|
||||
if (sPtr->flags.continuous && sPtr->action) {
|
||||
(*sPtr->action)(sPtr, sPtr->clientData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,10 +554,10 @@ static void
|
||||
destroySlider(Slider *sPtr)
|
||||
{
|
||||
if (sPtr->knobPixmap)
|
||||
XFreePixmap(sPtr->view->screen->display, sPtr->knobPixmap);
|
||||
XFreePixmap(sPtr->view->screen->display, sPtr->knobPixmap);
|
||||
|
||||
if (sPtr->backPixmap)
|
||||
WMReleasePixmap(sPtr->backPixmap);
|
||||
WMReleasePixmap(sPtr->backPixmap);
|
||||
|
||||
WMRemoveNotificationObserver(sPtr);
|
||||
|
||||
|
||||
+297
-296
@@ -5,11 +5,11 @@
|
||||
#include "WINGsP.h"
|
||||
|
||||
/*
|
||||
char *WMSplitViewDidResizeSubviewsNotification
|
||||
= "WMSplitViewDidResizeSubviewsNotification";
|
||||
char *WMSplitViewWillResizeSubviewsNotification
|
||||
= "WMSplitViewWillResizeSubviewsNotification";
|
||||
*/
|
||||
char *WMSplitViewDidResizeSubviewsNotification
|
||||
= "WMSplitViewDidResizeSubviewsNotification";
|
||||
char *WMSplitViewWillResizeSubviewsNotification
|
||||
= "WMSplitViewWillResizeSubviewsNotification";
|
||||
*/
|
||||
|
||||
typedef struct W_SplitViewSubview {
|
||||
WMView *view;
|
||||
@@ -23,15 +23,15 @@ typedef struct W_SplitViewSubview {
|
||||
typedef struct W_SplitView {
|
||||
W_Class widgetClass;
|
||||
W_View *view;
|
||||
|
||||
|
||||
WMArray *subviews;
|
||||
|
||||
|
||||
WMSplitViewConstrainProc *constrainProc;
|
||||
|
||||
|
||||
struct {
|
||||
unsigned int vertical:1;
|
||||
unsigned int adjustOnPaint:1;
|
||||
unsigned int subviewsWereManuallyMoved:1;
|
||||
unsigned int vertical:1;
|
||||
unsigned int adjustOnPaint:1;
|
||||
unsigned int subviewsWereManuallyMoved:1;
|
||||
} flags;
|
||||
|
||||
/* WMSplitViewResizeSubviewsProc *resizeSubviewsProc; */
|
||||
@@ -48,28 +48,28 @@ typedef struct W_SplitView {
|
||||
#define _GetSubviewsCount() WMGetArrayItemCount(sPtr->subviews)
|
||||
|
||||
#define _AddPSubviewStruct(P) \
|
||||
(WMAddToArray(sPtr->subviews,((void*)P)))
|
||||
(WMAddToArray(sPtr->subviews,((void*)P)))
|
||||
|
||||
#define _GetPSubviewStructAt(i) \
|
||||
((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))
|
||||
((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))
|
||||
|
||||
#define _GetSubviewAt(i) \
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->view)
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->view)
|
||||
|
||||
#define _GetMinSizeAt(i) \
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->minSize)
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->minSize)
|
||||
|
||||
#define _GetMaxSizeAt(i) \
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->maxSize)
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->maxSize)
|
||||
|
||||
#define _GetSizeAt(i) \
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->size)
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->size)
|
||||
|
||||
#define _GetPosAt(i) \
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->pos)
|
||||
(((W_SplitViewSubview*)WMGetFromArray(sPtr->subviews,(i)))->pos)
|
||||
|
||||
#define _GetSplitViewSize() \
|
||||
((sPtr->flags.vertical) ? sPtr->view->size.width : sPtr->view->size.height)
|
||||
((sPtr->flags.vertical) ? sPtr->view->size.width : sPtr->view->size.height)
|
||||
|
||||
static void destroySplitView(WMSplitView *sPtr);
|
||||
static void paintSplitView(WMSplitView *sPtr);
|
||||
@@ -85,15 +85,15 @@ getConstraints(WMSplitView *sPtr, int index, int *minSize, int *maxSize)
|
||||
*maxSize = MAX_SUBVIEW_SIZE;
|
||||
|
||||
if (sPtr->constrainProc)
|
||||
(*sPtr->constrainProc)(sPtr, index, minSize, maxSize);
|
||||
(*sPtr->constrainProc)(sPtr, index, minSize, maxSize);
|
||||
|
||||
if (*minSize < MIN_SUBVIEW_SIZE)
|
||||
*minSize = MIN_SUBVIEW_SIZE;
|
||||
*minSize = MIN_SUBVIEW_SIZE;
|
||||
|
||||
if (*maxSize < MIN_SUBVIEW_SIZE)
|
||||
*maxSize = MAX_SUBVIEW_SIZE;
|
||||
*maxSize = MAX_SUBVIEW_SIZE;
|
||||
else if (*maxSize < *minSize)
|
||||
*maxSize = *minSize;
|
||||
*maxSize = *minSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,8 @@ updateConstraints(WMSplitView *sPtr)
|
||||
|
||||
count = _GetSubviewsCount();
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
getConstraints(sPtr, i, &(p->minSize), &(p->maxSize));
|
||||
p = _GetPSubviewStructAt(i);
|
||||
getConstraints(sPtr, i, &(p->minSize), &(p->maxSize));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,17 +117,17 @@ resizeView(WMSplitView *sPtr, WMView *view, int size)
|
||||
int width, height;
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
width = size;
|
||||
height = sPtr->view->size.height;
|
||||
width = size;
|
||||
height = sPtr->view->size.height;
|
||||
} else {
|
||||
width = sPtr->view->size.width;
|
||||
height = size;
|
||||
width = sPtr->view->size.width;
|
||||
height = size;
|
||||
}
|
||||
|
||||
if (view->self)
|
||||
WMResizeWidget(view->self, width, height);
|
||||
WMResizeWidget(view->self, width, height);
|
||||
else
|
||||
W_ResizeView(view, width, height);
|
||||
W_ResizeView(view, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,11 +137,11 @@ reparentView(WMSplitView *sPtr, WMView *view, int pos)
|
||||
int x, y;
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
x = pos;
|
||||
y = 0;
|
||||
x = pos;
|
||||
y = 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = pos;
|
||||
x = 0;
|
||||
y = pos;
|
||||
}
|
||||
|
||||
W_ReparentView(view, sPtr->view, x, y);
|
||||
@@ -154,17 +154,17 @@ moveView(WMSplitView *sPtr, WMView *view, int pos)
|
||||
int x, y;
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
x = pos;
|
||||
y = 0;
|
||||
x = pos;
|
||||
y = 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = pos;
|
||||
x = 0;
|
||||
y = pos;
|
||||
}
|
||||
|
||||
if (view->self)
|
||||
WMMoveWidget(view->self, x, y);
|
||||
WMMoveWidget(view->self, x, y);
|
||||
else
|
||||
W_MoveView(view, x, y);
|
||||
W_MoveView(view, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -177,16 +177,16 @@ checkSizes(WMSplitView *sPtr)
|
||||
count = _GetSubviewsCount();
|
||||
offset = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (p->size < p->minSize) {
|
||||
offset += p->minSize - p->size;
|
||||
p->size = p->minSize;
|
||||
} else if (p->maxSize != MAX_SUBVIEW_SIZE && p->size > p->maxSize) {
|
||||
offset += p->maxSize - p->size;
|
||||
p->size = p->maxSize;
|
||||
}
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (p->size < p->minSize) {
|
||||
offset += p->minSize - p->size;
|
||||
p->size = p->minSize;
|
||||
} else if (p->maxSize != MAX_SUBVIEW_SIZE && p->size > p->maxSize) {
|
||||
offset += p->maxSize - p->size;
|
||||
p->size = p->maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (offset);
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ checkPositions(WMSplitView *sPtr)
|
||||
count = _GetSubviewsCount();
|
||||
pos = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
p->pos = pos;
|
||||
pos += p->size + DIVIDER_THICKNESS;
|
||||
p = _GetPSubviewStructAt(i);
|
||||
p->pos = pos;
|
||||
pos += p->size + DIVIDER_THICKNESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,9 +215,9 @@ updateSubviewsGeom(WMSplitView *sPtr)
|
||||
|
||||
count = _GetSubviewsCount();
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
resizeView(sPtr, p->view, p->size);
|
||||
moveView(sPtr, p->view, p->pos);
|
||||
p = _GetPSubviewStructAt(i);
|
||||
resizeView(sPtr, p->view, p->size);
|
||||
moveView(sPtr, p->view, p->pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,12 +229,12 @@ getTotalSize(WMSplitView *sPtr)
|
||||
|
||||
count = _GetSubviewsCount();
|
||||
if (!count)
|
||||
return (0);
|
||||
return (0);
|
||||
|
||||
totSize = 0;
|
||||
for (i = 0; i < count; i++)
|
||||
totSize += _GetSizeAt(i) + DIVIDER_THICKNESS;
|
||||
|
||||
totSize += _GetSizeAt(i) + DIVIDER_THICKNESS;
|
||||
|
||||
return (totSize - DIVIDER_THICKNESS);
|
||||
}
|
||||
|
||||
@@ -246,36 +246,36 @@ distributeOffsetEqually(WMSplitView *sPtr, int offset)
|
||||
int i, count, sizeChanged, forced;
|
||||
|
||||
if ((count = _GetSubviewsCount()) < 1)
|
||||
return (True);
|
||||
return (True);
|
||||
|
||||
forced = False;
|
||||
while (offset != 0) {
|
||||
sizeChanged = 0;
|
||||
for (i = 0; i < count && offset != 0; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (offset < 0) {
|
||||
if (p->size > p->minSize) {
|
||||
offset++;
|
||||
p->size--;
|
||||
sizeChanged = 1;
|
||||
}
|
||||
} else if (p->maxSize == MAX_SUBVIEW_SIZE || p->size < p->maxSize) {
|
||||
offset--;
|
||||
p->size++;
|
||||
sizeChanged = 1;
|
||||
}
|
||||
}
|
||||
if (offset != 0 && !sizeChanged) {
|
||||
p = _GetPSubviewStructAt(count-1);
|
||||
if (offset > 0) {
|
||||
p->size += offset;
|
||||
p->maxSize = MAX_SUBVIEW_SIZE;
|
||||
}
|
||||
offset = 0;
|
||||
forced = True;
|
||||
}
|
||||
sizeChanged = 0;
|
||||
for (i = 0; i < count && offset != 0; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (offset < 0) {
|
||||
if (p->size > p->minSize) {
|
||||
offset++;
|
||||
p->size--;
|
||||
sizeChanged = 1;
|
||||
}
|
||||
} else if (p->maxSize == MAX_SUBVIEW_SIZE || p->size < p->maxSize) {
|
||||
offset--;
|
||||
p->size++;
|
||||
sizeChanged = 1;
|
||||
}
|
||||
}
|
||||
if (offset != 0 && !sizeChanged) {
|
||||
p = _GetPSubviewStructAt(count-1);
|
||||
if (offset > 0) {
|
||||
p->size += offset;
|
||||
p->maxSize = MAX_SUBVIEW_SIZE;
|
||||
}
|
||||
offset = 0;
|
||||
forced = True;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (forced);
|
||||
}
|
||||
|
||||
@@ -287,23 +287,23 @@ distributeOffsetFormEnd(WMSplitView *sPtr, int offset)
|
||||
int i, count, sizeTmp;
|
||||
|
||||
if ((count = _GetSubviewsCount()) < 1)
|
||||
return (True);
|
||||
return (True);
|
||||
|
||||
for (i = count-1; i >= 0 && offset != 0; i--) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
sizeTmp = p->size;
|
||||
if (offset > 0) {
|
||||
if (p->maxSize == MAX_SUBVIEW_SIZE || p->size + offset < p->maxSize)
|
||||
p->size += offset;
|
||||
else
|
||||
p->size = p->maxSize;
|
||||
} else {
|
||||
if (p->size + offset >= p->minSize)
|
||||
p->size += offset;
|
||||
else
|
||||
p->size = p->minSize;
|
||||
}
|
||||
offset -= p->size - sizeTmp;
|
||||
p = _GetPSubviewStructAt(i);
|
||||
sizeTmp = p->size;
|
||||
if (offset > 0) {
|
||||
if (p->maxSize == MAX_SUBVIEW_SIZE || p->size + offset < p->maxSize)
|
||||
p->size += offset;
|
||||
else
|
||||
p->size = p->maxSize;
|
||||
} else {
|
||||
if (p->size + offset >= p->minSize)
|
||||
p->size += offset;
|
||||
else
|
||||
p->size = p->minSize;
|
||||
}
|
||||
offset -= p->size - sizeTmp;
|
||||
}
|
||||
|
||||
return (offset == 0);
|
||||
@@ -324,23 +324,23 @@ adjustSplitViewSubviews(WMSplitView *sPtr)
|
||||
#endif
|
||||
|
||||
if ((count = _GetSubviewsCount()) < 1)
|
||||
return;
|
||||
return;
|
||||
|
||||
adjSize = (_GetSplitViewSize() - ((count-1) * DIVIDER_THICKNESS)) / count;
|
||||
adjPad = (_GetSplitViewSize() - ((count-1) * DIVIDER_THICKNESS)) % count;
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
p->size = adjSize;
|
||||
p = _GetPSubviewStructAt(i);
|
||||
p->size = adjSize;
|
||||
}
|
||||
|
||||
|
||||
distributeOffsetEqually(sPtr, adjPad - checkSizes(sPtr));
|
||||
|
||||
|
||||
checkPositions(sPtr);
|
||||
updateSubviewsGeom(sPtr);
|
||||
|
||||
|
||||
sPtr->flags.subviewsWereManuallyMoved = 0;
|
||||
|
||||
#if 0
|
||||
#if 0
|
||||
printf("---- (adjustSplitViewSubviews - 2) ----\n");
|
||||
dumpSubviews(sPtr);
|
||||
#endif
|
||||
@@ -355,25 +355,25 @@ handleSubviewResized(void *self, WMNotification *notif)
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
|
||||
if (WMGetNotificationName(notif) == WMViewSizeDidChangeNotification) {
|
||||
W_SplitViewSubview *p;
|
||||
int i, count, done;
|
||||
WMView *view = WMGetNotificationObject(notif);
|
||||
W_SplitViewSubview *p;
|
||||
int i, count, done;
|
||||
WMView *view = WMGetNotificationObject(notif);
|
||||
|
||||
count = _GetSubviewsCount();
|
||||
done = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (p->view == view) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
/* TODO !!! */
|
||||
resizeView(sPtr, p->view, p->size);
|
||||
moveView(sPtr, p->view, p->pos);
|
||||
}
|
||||
count = _GetSubviewsCount();
|
||||
done = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (p->view == view) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
/* TODO !!! */
|
||||
resizeView(sPtr, p->view, p->size);
|
||||
moveView(sPtr, p->view, p->pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -390,13 +390,13 @@ handleViewResized(void *self, WMNotification *notification)
|
||||
|
||||
updateConstraints(sPtr);
|
||||
checkSizes(sPtr);
|
||||
|
||||
|
||||
if (sPtr->constrainProc || sPtr->flags.subviewsWereManuallyMoved) {
|
||||
distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr));
|
||||
checkPositions(sPtr);
|
||||
updateSubviewsGeom(sPtr);
|
||||
distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr));
|
||||
checkPositions(sPtr);
|
||||
updateSubviewsGeom(sPtr);
|
||||
} else
|
||||
adjustSplitViewSubviews(sPtr);
|
||||
adjustSplitViewSubviews(sPtr);
|
||||
|
||||
assert(checkSizes(sPtr) == 0);
|
||||
|
||||
@@ -419,47 +419,47 @@ paintSplitView(WMSplitView *sPtr)
|
||||
printf("---- (paintSplitView - 1) ----\n");
|
||||
dumpSubviews(sPtr);
|
||||
#endif
|
||||
|
||||
|
||||
if (!sPtr->view->flags.mapped || !sPtr->view->flags.realized)
|
||||
return;
|
||||
return;
|
||||
|
||||
XClearWindow(scr->display, sPtr->view->window);
|
||||
|
||||
count = _GetSubviewsCount();
|
||||
if (count == 0)
|
||||
return;
|
||||
return;
|
||||
|
||||
if (sPtr->flags.adjustOnPaint) {
|
||||
handleViewResized(sPtr, NULL);
|
||||
sPtr->flags.adjustOnPaint = 0;
|
||||
handleViewResized(sPtr, NULL);
|
||||
sPtr->flags.adjustOnPaint = 0;
|
||||
}
|
||||
|
||||
XSetClipMask(scr->display, scr->clipGC, dimple->mask);
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
x = ((DIVIDER_THICKNESS - dimple->width) / 2);
|
||||
y = (sPtr->view->size.height - dimple->height)/2;
|
||||
x = ((DIVIDER_THICKNESS - dimple->width) / 2);
|
||||
y = (sPtr->view->size.height - dimple->height)/2;
|
||||
} else {
|
||||
x = (sPtr->view->size.width - dimple->width)/2;
|
||||
y = ((DIVIDER_THICKNESS - dimple->height) / 2);
|
||||
x = (sPtr->view->size.width - dimple->width)/2;
|
||||
y = ((DIVIDER_THICKNESS - dimple->height) / 2);
|
||||
}
|
||||
|
||||
for (i = 0; i < count-1; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
p = _GetPSubviewStructAt(i);
|
||||
|
||||
if (sPtr->flags.vertical)
|
||||
x += p->size;
|
||||
else
|
||||
y += p->size;
|
||||
if (sPtr->flags.vertical)
|
||||
x += p->size;
|
||||
else
|
||||
y += p->size;
|
||||
|
||||
XSetClipOrigin(scr->display, scr->clipGC, x, y);
|
||||
XCopyArea(scr->display, dimple->pixmap, sPtr->view->window,
|
||||
scr->clipGC, 0, 0, dimple->width, dimple->height, x, y);
|
||||
|
||||
if (sPtr->flags.vertical)
|
||||
x += DIVIDER_THICKNESS;
|
||||
else
|
||||
y += DIVIDER_THICKNESS;
|
||||
XSetClipOrigin(scr->display, scr->clipGC, x, y);
|
||||
XCopyArea(scr->display, dimple->pixmap, sPtr->view->window,
|
||||
scr->clipGC, 0, 0, dimple->width, dimple->height, x, y);
|
||||
|
||||
if (sPtr->flags.vertical)
|
||||
x += DIVIDER_THICKNESS;
|
||||
else
|
||||
y += DIVIDER_THICKNESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -473,21 +473,21 @@ static void
|
||||
drawDragingRectangle(WMSplitView *sPtr, int pos)
|
||||
{
|
||||
int x, y, w, h;
|
||||
|
||||
|
||||
if (sPtr->flags.vertical) {
|
||||
x = pos;
|
||||
y = 0;
|
||||
w = DIVIDER_THICKNESS;
|
||||
h = sPtr->view->size.height;
|
||||
x = pos;
|
||||
y = 0;
|
||||
w = DIVIDER_THICKNESS;
|
||||
h = sPtr->view->size.height;
|
||||
} else {
|
||||
x = 0;
|
||||
y = pos;
|
||||
w = sPtr->view->size.width;
|
||||
h = DIVIDER_THICKNESS;
|
||||
x = 0;
|
||||
y = pos;
|
||||
w = sPtr->view->size.width;
|
||||
h = DIVIDER_THICKNESS;
|
||||
}
|
||||
|
||||
|
||||
XFillRectangle(sPtr->view->screen->display, sPtr->view->window,
|
||||
sPtr->view->screen->ixorGC, x, y, w, h);
|
||||
sPtr->view->screen->ixorGC, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
@@ -499,14 +499,14 @@ getMinMaxDividerCoord(WMSplitView *sPtr, int divider, int *minC, int *maxC)
|
||||
|
||||
relMinC = _GetMinSizeAt(divider);
|
||||
if (_GetMaxSizeAt(divider+1) != MAX_SUBVIEW_SIZE
|
||||
&& relMinC < totSize - _GetMaxSizeAt(divider+1))
|
||||
relMinC = totSize - _GetMaxSizeAt(divider+1);
|
||||
&& relMinC < totSize - _GetMaxSizeAt(divider+1))
|
||||
relMinC = totSize - _GetMaxSizeAt(divider+1);
|
||||
|
||||
relMaxC = totSize - _GetMinSizeAt(divider+1);
|
||||
if (_GetMaxSizeAt(divider) != MAX_SUBVIEW_SIZE
|
||||
&& relMaxC > _GetMaxSizeAt(divider))
|
||||
relMaxC = _GetMaxSizeAt(divider);
|
||||
|
||||
&& relMaxC > _GetMaxSizeAt(divider))
|
||||
relMaxC = _GetMaxSizeAt(divider);
|
||||
|
||||
*minC = _GetPosAt(divider) + relMinC;
|
||||
*maxC = _GetPosAt(divider) + relMaxC;
|
||||
}
|
||||
@@ -522,11 +522,11 @@ dragDivider(WMSplitView *sPtr, int clickX, int clickY)
|
||||
int minCoord, maxCoord, coord;
|
||||
|
||||
if (sPtr->constrainProc) {
|
||||
updateConstraints(sPtr);
|
||||
checkSizes(sPtr);
|
||||
distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr));
|
||||
checkPositions(sPtr);
|
||||
updateSubviewsGeom(sPtr);
|
||||
updateConstraints(sPtr);
|
||||
checkSizes(sPtr);
|
||||
distributeOffsetFormEnd(sPtr, _GetSplitViewSize() - getTotalSize(sPtr));
|
||||
checkPositions(sPtr);
|
||||
updateSubviewsGeom(sPtr);
|
||||
}
|
||||
|
||||
scr = sPtr->view->screen;
|
||||
@@ -534,74 +534,74 @@ dragDivider(WMSplitView *sPtr, int clickX, int clickY)
|
||||
coord = (sPtr->flags.vertical) ? clickX : clickY;
|
||||
count = _GetSubviewsCount();
|
||||
if (count < 2)
|
||||
return;
|
||||
return;
|
||||
|
||||
for (i = 0; i < count-1; i++) {
|
||||
pos += _GetSizeAt(i) + DIVIDER_THICKNESS;
|
||||
if (coord < pos) {
|
||||
ofs = coord - pos + DIVIDER_THICKNESS;
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
divider++;
|
||||
pos += _GetSizeAt(i) + DIVIDER_THICKNESS;
|
||||
if (coord < pos) {
|
||||
ofs = coord - pos + DIVIDER_THICKNESS;
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
divider++;
|
||||
}
|
||||
|
||||
if (!done)
|
||||
return;
|
||||
return;
|
||||
|
||||
getMinMaxDividerCoord(sPtr, divider, &minCoord, &maxCoord);
|
||||
|
||||
done = 0;
|
||||
dragging = 0;
|
||||
while (!done) {
|
||||
WMMaskEvent(scr->display, ButtonMotionMask|ButtonReleaseMask
|
||||
|ExposureMask, &ev);
|
||||
WMMaskEvent(scr->display, ButtonMotionMask|ButtonReleaseMask
|
||||
|ExposureMask, &ev);
|
||||
|
||||
coord = (sPtr->flags.vertical) ? ev.xmotion.x : ev.xmotion.y;
|
||||
coord = (sPtr->flags.vertical) ? ev.xmotion.x : ev.xmotion.y;
|
||||
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
done = 1;
|
||||
if (dragging)
|
||||
drawDragingRectangle(sPtr, pos);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (dragging)
|
||||
drawDragingRectangle(sPtr, pos);
|
||||
if (coord - ofs < minCoord)
|
||||
pos = minCoord;
|
||||
else if (coord - ofs > maxCoord)
|
||||
pos = maxCoord;
|
||||
else
|
||||
pos = coord - ofs;
|
||||
drawDragingRectangle(sPtr, pos);
|
||||
dragging = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
WMHandleEvent(&ev);
|
||||
break;
|
||||
}
|
||||
switch (ev.type) {
|
||||
case ButtonRelease:
|
||||
done = 1;
|
||||
if (dragging)
|
||||
drawDragingRectangle(sPtr, pos);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
if (dragging)
|
||||
drawDragingRectangle(sPtr, pos);
|
||||
if (coord - ofs < minCoord)
|
||||
pos = minCoord;
|
||||
else if (coord - ofs > maxCoord)
|
||||
pos = maxCoord;
|
||||
else
|
||||
pos = coord - ofs;
|
||||
drawDragingRectangle(sPtr, pos);
|
||||
dragging = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
WMHandleEvent(&ev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (dragging) {
|
||||
W_SplitViewSubview *p1, *p2;
|
||||
int totSize;
|
||||
|
||||
p1 = _GetPSubviewStructAt(divider);
|
||||
p2 = _GetPSubviewStructAt(divider+1);
|
||||
|
||||
totSize = p1->size + DIVIDER_THICKNESS + p2->size;
|
||||
|
||||
p1->size = pos - p1->pos;
|
||||
p2->size = totSize - p1->size - DIVIDER_THICKNESS;
|
||||
p2->pos = p1->pos + p1->size + DIVIDER_THICKNESS;
|
||||
|
||||
resizeView(sPtr, p1->view, p1->size);
|
||||
moveView(sPtr, p2->view, p2->pos);
|
||||
resizeView(sPtr, p2->view, p2->size);
|
||||
sPtr->flags.subviewsWereManuallyMoved = 1;
|
||||
W_SplitViewSubview *p1, *p2;
|
||||
int totSize;
|
||||
|
||||
p1 = _GetPSubviewStructAt(divider);
|
||||
p2 = _GetPSubviewStructAt(divider+1);
|
||||
|
||||
totSize = p1->size + DIVIDER_THICKNESS + p2->size;
|
||||
|
||||
p1->size = pos - p1->pos;
|
||||
p2->size = totSize - p1->size - DIVIDER_THICKNESS;
|
||||
p2->pos = p1->pos + p1->size + DIVIDER_THICKNESS;
|
||||
|
||||
resizeView(sPtr, p1->view, p1->size);
|
||||
moveView(sPtr, p2->view, p2->pos);
|
||||
resizeView(sPtr, p2->view, p2->size);
|
||||
sPtr->flags.subviewsWereManuallyMoved = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,16 +614,16 @@ handleEvents(XEvent *event, void *data)
|
||||
CHECK_CLASS(data, WC_SplitView);
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintSplitView(sPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroySplitView(sPtr);
|
||||
break;
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintSplitView(sPtr);
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroySplitView(sPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,14 +631,14 @@ handleEvents(XEvent *event, void *data)
|
||||
static void
|
||||
handleActionEvents(XEvent *event, void *data)
|
||||
{
|
||||
|
||||
|
||||
CHECK_CLASS(data, WC_SplitView);
|
||||
|
||||
switch (event->type) {
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button == Button1)
|
||||
dragDivider(data, event->xbutton.x, event->xbutton.y);
|
||||
break;
|
||||
case ButtonPress:
|
||||
if (event->xbutton.button == Button1)
|
||||
dragDivider(data, event->xbutton.x, event->xbutton.y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,27 +663,27 @@ WMCreateSplitView(WMWidget *parent)
|
||||
memset(sPtr, 0, sizeof(WMSplitView));
|
||||
|
||||
sPtr->widgetClass = WC_SplitView;
|
||||
|
||||
|
||||
sPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!sPtr->view) {
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
wfree(sPtr);
|
||||
return NULL;
|
||||
}
|
||||
sPtr->view->self = sPtr;
|
||||
|
||||
WMSetViewNotifySizeChanges(sPtr->view, True);
|
||||
|
||||
WMCreateEventHandler(sPtr->view, ExposureMask|StructureNotifyMask
|
||||
|ClientMessageMask, handleEvents, sPtr);
|
||||
|ClientMessageMask, handleEvents, sPtr);
|
||||
|
||||
|
||||
WMCreateEventHandler(sPtr->view, ButtonPressMask|ButtonReleaseMask
|
||||
|EnterWindowMask|LeaveWindowMask,
|
||||
handleActionEvents, sPtr);
|
||||
|EnterWindowMask|LeaveWindowMask,
|
||||
handleActionEvents, sPtr);
|
||||
|
||||
|
||||
WMAddNotificationObserver(handleViewResized, sPtr,
|
||||
WMViewSizeDidChangeNotification, sPtr->view);
|
||||
WMAddNotificationObserver(handleViewResized, sPtr,
|
||||
WMViewSizeDidChangeNotification, sPtr->view);
|
||||
|
||||
sPtr->subviews = WMCreateArrayWithDestructor(8, wfree);
|
||||
|
||||
@@ -695,7 +695,7 @@ void
|
||||
WMAdjustSplitViewSubviews(WMSplitView *sPtr)
|
||||
{
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
|
||||
|
||||
checkSizes(sPtr);
|
||||
|
||||
adjustSplitViewSubviews(sPtr);
|
||||
@@ -713,42 +713,42 @@ WMAddSplitViewSubview(WMSplitView *sPtr, WMView *subview)
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
|
||||
if (!(p = (W_SplitViewSubview*)wmalloc(sizeof(W_SplitViewSubview))))
|
||||
return;
|
||||
return;
|
||||
|
||||
wasMapped = subview->flags.mapped;
|
||||
if (wasMapped)
|
||||
W_UnmapView(subview);
|
||||
W_UnmapView(subview);
|
||||
|
||||
count = _GetSubviewsCount();
|
||||
p->view = subview;
|
||||
getConstraints(sPtr, count, &(p->minSize), &(p->maxSize));
|
||||
if (sPtr->flags.vertical)
|
||||
p->size = subview->size.width;
|
||||
p->size = subview->size.width;
|
||||
else
|
||||
p->size = subview->size.height;
|
||||
p->size = subview->size.height;
|
||||
|
||||
WMAddToArray(sPtr->subviews, p);
|
||||
reparentView(sPtr, subview, 0);
|
||||
|
||||
/*
|
||||
We should have something like that...
|
||||
|
||||
WMSetViewNotifySizeChanges(subview, True);
|
||||
WMAddNotificationObserver(handleSubviewResized, sPtr,
|
||||
WMViewSizeDidChangeNotification,
|
||||
subview);
|
||||
WMSetViewNotifyMoveChanges(subview, True);
|
||||
WMAddNotificationObserver(handleSubviewResized, sPtr,
|
||||
WMViewMoveDidChangeNotification,
|
||||
subview);
|
||||
*/
|
||||
if (wasMapped) {
|
||||
W_MapView(subview);
|
||||
/*
|
||||
We should have something like that...
|
||||
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
WMSetViewNotifySizeChanges(subview, True);
|
||||
WMAddNotificationObserver(handleSubviewResized, sPtr,
|
||||
WMViewSizeDidChangeNotification,
|
||||
subview);
|
||||
WMSetViewNotifyMoveChanges(subview, True);
|
||||
WMAddNotificationObserver(handleSubviewResized, sPtr,
|
||||
WMViewMoveDidChangeNotification,
|
||||
subview);
|
||||
*/
|
||||
if (wasMapped) {
|
||||
W_MapView(subview);
|
||||
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
} else {
|
||||
handleViewResized(sPtr, NULL);
|
||||
handleViewResized(sPtr, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,9 +759,9 @@ WMGetSplitViewSubviewAt(WMSplitView *sPtr, int index)
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
|
||||
if (index >= 0 && index < _GetSubviewsCount())
|
||||
return (_GetSubviewAt(index));
|
||||
return (_GetSubviewAt(index));
|
||||
else
|
||||
return (NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -776,13 +776,13 @@ WMRemoveSplitViewSubview(WMSplitView *sPtr, WMView *view)
|
||||
/* TODO: rewrite this. This code with macros is getting more complex than it worths */
|
||||
count = _GetSubviewsCount();
|
||||
for (i = 0; i < count; i++) {
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (p->view == view) {
|
||||
WMDeleteFromArray(sPtr->subviews, i);
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
break;
|
||||
}
|
||||
p = _GetPSubviewStructAt(i);
|
||||
if (p->view == view) {
|
||||
WMDeleteFromArray(sPtr->subviews, i);
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -796,15 +796,15 @@ WMRemoveSplitViewSubviewAt(WMSplitView *sPtr, int index)
|
||||
|
||||
/* TODO: same about rewrite */
|
||||
if (index >= 0 && index < _GetSubviewsCount()) {
|
||||
p = _GetPSubviewStructAt(index);
|
||||
WMDeleteFromArray(sPtr->subviews, index);
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
p = _GetPSubviewStructAt(index);
|
||||
WMDeleteFromArray(sPtr->subviews, index);
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
paintSplitView(sPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
WMSetSplitViewConstrainProc(WMSplitView *sPtr, WMSplitViewConstrainProc *proc)
|
||||
{
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
@@ -834,20 +834,20 @@ void
|
||||
WMSetSplitViewVertical(WMSplitView *sPtr, Bool flag)
|
||||
{
|
||||
int vertical;
|
||||
|
||||
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
|
||||
vertical = ((flag==0) ? 0 : 1);
|
||||
if (sPtr->flags.vertical == vertical)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
sPtr->flags.vertical = vertical;
|
||||
|
||||
/* if (sPtr->view->flags.mapped && sPtr->view->flags.realized)*/
|
||||
handleViewResized(sPtr, NULL);
|
||||
/* else
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
*/
|
||||
|
||||
/* if (sPtr->view->flags.mapped && sPtr->view->flags.realized)*/
|
||||
handleViewResized(sPtr, NULL);
|
||||
/* else
|
||||
sPtr->flags.adjustOnPaint = 1;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -861,11 +861,12 @@ WMGetSplitViewDividerThickness(WMSplitView *sPtr)
|
||||
|
||||
#if 0
|
||||
void
|
||||
WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
WMSplitViewResizeSubviewsProc *proc)
|
||||
WMSetSplitViewResizeSubviewsProc(WMSplitView *sPtr,
|
||||
WMSplitViewResizeSubviewsProc *proc)
|
||||
{
|
||||
CHECK_CLASS(sPtr, WC_SplitView);
|
||||
|
||||
sPtr->resizeSubviewsProc = proc;
|
||||
}
|
||||
#endif
|
||||
|
||||
+327
-326
@@ -12,7 +12,7 @@ typedef struct W_TabView {
|
||||
|
||||
int selectedItem;
|
||||
int firstVisible;
|
||||
|
||||
|
||||
int visibleTabs;
|
||||
|
||||
WMFont *font;
|
||||
@@ -25,15 +25,15 @@ typedef struct W_TabView {
|
||||
short tabHeight;
|
||||
|
||||
struct {
|
||||
WMReliefType relief:4;
|
||||
WMTitlePosition titlePosition:4;
|
||||
WMTabViewType type:2;
|
||||
WMReliefType relief:4;
|
||||
WMTitlePosition titlePosition:4;
|
||||
WMTabViewType type:2;
|
||||
|
||||
unsigned enabled:1;
|
||||
unsigned tabbed:1;
|
||||
unsigned dontFitAll:1;
|
||||
unsigned bordered:1;
|
||||
unsigned uniformTabs:1;
|
||||
unsigned enabled:1;
|
||||
unsigned tabbed:1;
|
||||
unsigned dontFitAll:1;
|
||||
unsigned bordered:1;
|
||||
unsigned uniformTabs:1;
|
||||
} flags;
|
||||
} TabView;
|
||||
|
||||
@@ -66,14 +66,14 @@ typedef struct W_TabViewItem {
|
||||
#define BUTTONED_SIDE_OFFSET 15
|
||||
|
||||
|
||||
static void destroyTabView(TabView *tPtr);
|
||||
static void destroyTabView(TabView *tPtr);
|
||||
static void paintTabView(TabView *tPtr);
|
||||
|
||||
|
||||
static void W_SetTabViewItemParent(WMTabViewItem *item, WMTabView *parent);
|
||||
|
||||
static void W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect,
|
||||
Bool enabled);
|
||||
Bool enabled);
|
||||
|
||||
static void W_UnmapTabViewItem(WMTabViewItem *item);
|
||||
|
||||
@@ -93,10 +93,10 @@ static void didResize(struct W_ViewDelegate*, WMView*);
|
||||
|
||||
static W_ViewDelegate delegate = {
|
||||
NULL,
|
||||
NULL,
|
||||
didResize,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
didResize,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -105,21 +105,21 @@ positionOfTab(WMTabView *tabView, int tab)
|
||||
{
|
||||
int i;
|
||||
int offs;
|
||||
|
||||
|
||||
if (tab < tabView->firstVisible)
|
||||
return -1;
|
||||
|
||||
return -1;
|
||||
|
||||
if (tab > tabView->firstVisible + tabView->visibleTabs)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
if (tabView->flags.dontFitAll)
|
||||
offs = BUTTONED_SIDE_OFFSET;
|
||||
offs = BUTTONED_SIDE_OFFSET;
|
||||
else
|
||||
offs = NORMAL_SIDE_OFFSET;
|
||||
|
||||
offs = NORMAL_SIDE_OFFSET;
|
||||
|
||||
for (i = tabView->firstVisible; i < tab; i++)
|
||||
offs += W_TabViewItemTabWidth(tabView->items[i]) - 10;
|
||||
|
||||
offs += W_TabViewItemTabWidth(tabView->items[i]) - 10;
|
||||
|
||||
return offs;
|
||||
}
|
||||
|
||||
@@ -131,17 +131,17 @@ countVisibleTabs(TabView *tPtr, int first)
|
||||
int width;
|
||||
|
||||
if (first < 0) {
|
||||
width = W_VIEW_WIDTH(tPtr->view) - 2 * NORMAL_SIDE_OFFSET;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
width -= W_TabViewItemTabWidth(tPtr->items[i]) - 10;
|
||||
if (width <= 0) {
|
||||
return i - first;
|
||||
}
|
||||
}
|
||||
return i - first;
|
||||
}
|
||||
@@ -156,49 +156,49 @@ handleEvents(XEvent *event, void *data)
|
||||
CHECK_CLASS(data, WC_TabView);
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintTabView(tPtr);
|
||||
break;
|
||||
case Expose:
|
||||
if (event->xexpose.count!=0)
|
||||
break;
|
||||
paintTabView(tPtr);
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
if (tPtr->flags.enabled) {
|
||||
WMTabViewItem *item = WMTabViewItemAtPoint(tPtr,
|
||||
event->xbutton.x,
|
||||
event->xbutton.y);
|
||||
case ButtonPress:
|
||||
if (tPtr->flags.enabled) {
|
||||
WMTabViewItem *item = WMTabViewItemAtPoint(tPtr,
|
||||
event->xbutton.x,
|
||||
event->xbutton.y);
|
||||
/*if (item && !item->flags.enabled)
|
||||
break;*/
|
||||
break;*/
|
||||
|
||||
if (item && item->flags.enabled) {
|
||||
WMSelectTabViewItem(tPtr, item);
|
||||
} else if (tPtr->flags.dontFitAll) {
|
||||
int redraw = 0;
|
||||
int lastVisible = tPtr->firstVisible+tPtr->visibleTabs-1;
|
||||
WMSelectTabViewItem(tPtr, item);
|
||||
} else if (tPtr->flags.dontFitAll) {
|
||||
int redraw = 0;
|
||||
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 > positionOfTab(tPtr,lastVisible)){
|
||||
if (event->xbutton.x < BUTTONED_SIDE_OFFSET) {
|
||||
if (tPtr->firstVisible > 0) {
|
||||
redraw = 1;
|
||||
tPtr->firstVisible--;
|
||||
}
|
||||
} else if (event->xbutton.x > positionOfTab(tPtr,lastVisible)){
|
||||
|
||||
if (lastVisible < tPtr->itemCount-1) {
|
||||
redraw = 1;
|
||||
tPtr->firstVisible++;
|
||||
}
|
||||
}
|
||||
tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible);
|
||||
if (redraw) {
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (lastVisible < tPtr->itemCount-1) {
|
||||
redraw = 1;
|
||||
tPtr->firstVisible++;
|
||||
}
|
||||
}
|
||||
tPtr->visibleTabs = countVisibleTabs(tPtr, tPtr->firstVisible);
|
||||
if (redraw) {
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DestroyNotify:
|
||||
destroyTabView(tPtr);
|
||||
break;
|
||||
case DestroyNotify:
|
||||
destroyTabView(tPtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@ WMCreateTabView(WMWidget *parent)
|
||||
|
||||
tPtr->view = W_CreateView(W_VIEW(parent));
|
||||
if (!tPtr->view) {
|
||||
wfree(tPtr);
|
||||
return NULL;
|
||||
wfree(tPtr);
|
||||
return NULL;
|
||||
}
|
||||
tPtr->view->self = tPtr;
|
||||
tPtr->view->delegate = &delegate;
|
||||
@@ -227,14 +227,14 @@ 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;
|
||||
tPtr->flags.enabled = 1;
|
||||
|
||||
WMCreateEventHandler(tPtr->view, ExposureMask|StructureNotifyMask
|
||||
|ButtonPressMask, handleEvents, tPtr);
|
||||
|ButtonPressMask, handleEvents, tPtr);
|
||||
|
||||
WMResizeWidget(tPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
|
||||
@@ -253,10 +253,10 @@ WMSetTabViewDelegate(WMTabView *tPtr, WMTabViewDelegate *delegate)
|
||||
|
||||
WMTabViewItem*
|
||||
WMAddTabViewItemWithView(WMTabView *tPtr, WMView *view, int identifier,
|
||||
char *label)
|
||||
char *label)
|
||||
{
|
||||
WMTabViewItem *item;
|
||||
|
||||
|
||||
item = WMCreateTabViewItemWithIdentifier(identifier);
|
||||
WMSetTabViewItemView(item, view);
|
||||
WMAddItemInTabView(tPtr, item);
|
||||
@@ -278,7 +278,7 @@ WMSetTabViewEnabled(WMTabView *tPtr, Bool flag)
|
||||
{
|
||||
tPtr->flags.enabled = ((flag==0) ? 0 : 1);
|
||||
if (W_VIEW_REALIZED(tPtr->view))
|
||||
paintTabView(tPtr);
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -288,25 +288,25 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
||||
wassertr(W_TabViewItemView(item) != NULL);
|
||||
|
||||
if (tPtr->maxItems == tPtr->itemCount) {
|
||||
WMTabViewItem **items;
|
||||
WMTabViewItem **items;
|
||||
|
||||
items = wrealloc(tPtr->items,
|
||||
sizeof(WMTabViewItem*) * (tPtr->maxItems + 10));
|
||||
memset(&items[tPtr->maxItems], 0, sizeof(WMTabViewItem*) * 10);
|
||||
tPtr->items = items;
|
||||
tPtr->maxItems += 10;
|
||||
items = wrealloc(tPtr->items,
|
||||
sizeof(WMTabViewItem*) * (tPtr->maxItems + 10));
|
||||
memset(&items[tPtr->maxItems], 0, sizeof(WMTabViewItem*) * 10);
|
||||
tPtr->items = items;
|
||||
tPtr->maxItems += 10;
|
||||
}
|
||||
|
||||
if (index > tPtr->itemCount)
|
||||
index = tPtr->itemCount;
|
||||
index = tPtr->itemCount;
|
||||
|
||||
if (index == 0 && tPtr->items[0]) {
|
||||
W_UnmapTabViewItem(tPtr->items[0]);
|
||||
W_UnmapTabViewItem(tPtr->items[0]);
|
||||
}
|
||||
|
||||
if (index < tPtr->itemCount) {
|
||||
memmove(tPtr->items + index + 1, tPtr->items + index,
|
||||
(tPtr->itemCount - index) * sizeof(WMTabViewItem*));
|
||||
memmove(tPtr->items + index + 1, tPtr->items + index,
|
||||
(tPtr->itemCount - index) * sizeof(WMTabViewItem*));
|
||||
}
|
||||
|
||||
tPtr->items[index] = item;
|
||||
@@ -320,27 +320,27 @@ WMInsertItemInTabView(WMTabView *tPtr, int index, WMTabViewItem *item)
|
||||
W_UnmapTabViewItem(item);
|
||||
|
||||
if (tPtr->flags.bordered) {
|
||||
W_ReparentView(W_TabViewItemView(item), tPtr->view, 1,
|
||||
tPtr->tabHeight + 1);
|
||||
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_ReparentView(W_TabViewItemView(item), tPtr->view, 0,
|
||||
tPtr->tabHeight);
|
||||
|
||||
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width,
|
||||
tPtr->view->size.height - tPtr->tabHeight);
|
||||
W_ResizeView(W_TabViewItemView(item), tPtr->view->size.width,
|
||||
tPtr->view->size.height - tPtr->tabHeight);
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
W_MapTabViewItem(item);
|
||||
W_MapTabViewItem(item);
|
||||
}
|
||||
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);
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -350,21 +350,21 @@ WMRemoveTabViewItem(WMTabView *tPtr, WMTabViewItem *item)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tPtr->itemCount; i++) {
|
||||
if (tPtr->items[i] == item) {
|
||||
if (i < tPtr->itemCount - 1)
|
||||
memmove(&tPtr->items[i], &tPtr->items[i + 1],
|
||||
tPtr->itemCount - i - 1);
|
||||
else
|
||||
tPtr->items[i] = NULL;
|
||||
if (tPtr->items[i] == item) {
|
||||
if (i < tPtr->itemCount - 1)
|
||||
memmove(&tPtr->items[i], &tPtr->items[i + 1],
|
||||
tPtr->itemCount - i - 1);
|
||||
else
|
||||
tPtr->items[i] = NULL;
|
||||
|
||||
W_SetTabViewItemParent(item, NULL);
|
||||
W_SetTabViewItemParent(item, NULL);
|
||||
|
||||
tPtr->itemCount--;
|
||||
break;
|
||||
}
|
||||
tPtr->itemCount--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tPtr->delegate && tPtr->delegate->didChangeNumberOfItems)
|
||||
(*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr);
|
||||
(*tPtr->delegate->didChangeNumberOfItems)(tPtr->delegate, tPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -373,22 +373,22 @@ static Bool
|
||||
isInside(int x, int y, int width, int height, int px, int py)
|
||||
{
|
||||
if (py >= y + height - 3 && py <= y + height
|
||||
&& px >= x + py - (y + height - 3)
|
||||
&& px <= x + width - (py - (y + height - 3))) {
|
||||
&& px >= x + py - (y + height - 3)
|
||||
&& px <= x + width - (py - (y + height - 3))) {
|
||||
|
||||
return True;
|
||||
return True;
|
||||
}
|
||||
if (py >= y + 3 && py < y + height - 3
|
||||
&& px >= x + 3 + ((y + 3) - py)*3/7
|
||||
&& px <= x + width - 3 - ((y + 3) - py)*3/7) {
|
||||
&& px >= x + 3 + ((y + 3) - py)*3/7
|
||||
&& px <= x + width - 3 - ((y + 3) - py)*3/7) {
|
||||
|
||||
return True;
|
||||
return True;
|
||||
}
|
||||
if (py >= y && py < y + 3
|
||||
&& px >= x + 7 + py - y
|
||||
&& px <= x + width - 7 - (py - y)) {
|
||||
&& px >= x + 7 + py - y
|
||||
&& px <= x + width - 7 - (py - y)) {
|
||||
|
||||
return True;
|
||||
return True;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
@@ -400,32 +400,32 @@ WMTabViewItemAtPoint(WMTabView *tPtr, int x, int y)
|
||||
int i;
|
||||
int count = tPtr->visibleTabs;
|
||||
int first = tPtr->firstVisible;
|
||||
|
||||
|
||||
if (tPtr->flags.dontFitAll) {
|
||||
i = tPtr->selectedItem - tPtr->firstVisible;
|
||||
if (i >= 0 && i < tPtr->visibleTabs
|
||||
&& isInside(positionOfTab(tPtr, tPtr->selectedItem), 0,
|
||||
W_TabViewItemTabWidth(tPtr->items[tPtr->selectedItem]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[tPtr->selectedItem];
|
||||
}
|
||||
i = tPtr->selectedItem - tPtr->firstVisible;
|
||||
if (i >= 0 && i < tPtr->visibleTabs
|
||||
&& isInside(positionOfTab(tPtr, tPtr->selectedItem), 0,
|
||||
W_TabViewItemTabWidth(tPtr->items[tPtr->selectedItem]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[tPtr->selectedItem];
|
||||
}
|
||||
} else {
|
||||
i = tPtr->selectedItem;
|
||||
if (isInside(positionOfTab(tPtr, i), 0,
|
||||
W_TabViewItemTabWidth(tPtr->items[i]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[i];
|
||||
}
|
||||
i = tPtr->selectedItem;
|
||||
if (isInside(positionOfTab(tPtr, i), 0,
|
||||
W_TabViewItemTabWidth(tPtr->items[i]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = first; i < first + count; i++) {
|
||||
int pos;
|
||||
int pos;
|
||||
|
||||
pos = positionOfTab(tPtr, i);
|
||||
if (isInside(pos, 0, W_TabViewItemTabWidth(tPtr->items[i]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[i];
|
||||
}
|
||||
pos = positionOfTab(tPtr, i);
|
||||
if (isInside(pos, 0, W_TabViewItemTabWidth(tPtr->items[i]),
|
||||
tPtr->tabHeight, x, y)) {
|
||||
return tPtr->items[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -435,17 +435,17 @@ void
|
||||
WMSetTabViewType(WMTabView *tPtr, WMTabViewType type)
|
||||
{
|
||||
tPtr->flags.type = type;
|
||||
|
||||
|
||||
if (type != WTTopTabsBevelBorder)
|
||||
tPtr->tabHeight = 0;
|
||||
tPtr->tabHeight = 0;
|
||||
else
|
||||
tPtr->tabHeight = WMFontHeight(tPtr->font) + 3;
|
||||
|
||||
tPtr->tabHeight = WMFontHeight(tPtr->font) + 3;
|
||||
|
||||
if (type == WTNoTabsNoBorder)
|
||||
tPtr->flags.bordered = 0;
|
||||
tPtr->flags.bordered = 0;
|
||||
else
|
||||
tPtr->flags.bordered = 1;
|
||||
|
||||
tPtr->flags.bordered = 1;
|
||||
|
||||
rearrange(tPtr);
|
||||
}
|
||||
|
||||
@@ -490,10 +490,10 @@ WMSelectTabViewItem(WMTabView *tPtr, WMTabViewItem *item)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tPtr->itemCount; i++) {
|
||||
if (tPtr->items[i] == item) {
|
||||
WMSelectTabViewItemAtIndex(tPtr, i);
|
||||
break;
|
||||
}
|
||||
if (tPtr->items[i] == item) {
|
||||
WMSelectTabViewItemAtIndex(tPtr, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,24 +504,24 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index)
|
||||
WMTabViewItem *item;
|
||||
|
||||
if (index == tPtr->selectedItem) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
index = 0;
|
||||
else if (index >= tPtr->itemCount)
|
||||
index = tPtr->itemCount - 1;
|
||||
index = tPtr->itemCount - 1;
|
||||
|
||||
item = tPtr->items[tPtr->selectedItem];
|
||||
|
||||
if (tPtr->delegate && tPtr->delegate->shouldSelectItem)
|
||||
if (!(*tPtr->delegate->shouldSelectItem)(tPtr->delegate, tPtr,
|
||||
tPtr->items[index]))
|
||||
return;
|
||||
if (!(*tPtr->delegate->shouldSelectItem)(tPtr->delegate, tPtr,
|
||||
tPtr->items[index]))
|
||||
return;
|
||||
|
||||
if (tPtr->delegate && tPtr->delegate->willSelectItem)
|
||||
(*tPtr->delegate->willSelectItem)(tPtr->delegate, tPtr,
|
||||
tPtr->items[index]);
|
||||
(*tPtr->delegate->willSelectItem)(tPtr->delegate, tPtr,
|
||||
tPtr->items[index]);
|
||||
|
||||
W_UnmapTabViewItem(item);
|
||||
|
||||
@@ -533,9 +533,9 @@ WMSelectTabViewItemAtIndex(WMTabView *tPtr, int index)
|
||||
tPtr->selectedItem = index;
|
||||
|
||||
if (tPtr->delegate && tPtr->delegate->didSelectItem)
|
||||
(*tPtr->delegate->didSelectItem)(tPtr->delegate, tPtr,
|
||||
tPtr->items[index]);
|
||||
|
||||
(*tPtr->delegate->didSelectItem)(tPtr->delegate, tPtr,
|
||||
tPtr->items[index]);
|
||||
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
|
||||
@@ -549,58 +549,58 @@ recalcTabWidth(TabView *tPtr)
|
||||
int width;
|
||||
|
||||
if (tPtr->flags.uniformTabs) {
|
||||
int tabWidth;
|
||||
|
||||
tabWidth = 0;
|
||||
int tabWidth;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
tabWidth = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
for (i = 0; i < tPtr->itemCount; i++) {
|
||||
char *str = WMGetTabViewItemLabel(tPtr->items[i]);
|
||||
if (!str)
|
||||
continue;
|
||||
|
||||
width = WMWidthOfString(tPtr->font, str, strlen(str)) + 30;
|
||||
width = WMWidthOfString(tPtr->font, str, strlen(str)) + 30;
|
||||
|
||||
W_SetTabViewItemTabWidth(tPtr->items[i], width);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
drawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
unsigned int height)
|
||||
unsigned int height)
|
||||
{
|
||||
Display *dpy = scr->display;
|
||||
GC bgc = WMColorGC(scr->black);
|
||||
@@ -618,8 +618,8 @@ drawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
|
||||
|
||||
|
||||
static void
|
||||
drawTab(TabView *tPtr, Drawable d, int x, int y,
|
||||
unsigned width, unsigned height, Bool selected)
|
||||
drawTab(TabView *tPtr, Drawable d, int x, int y,
|
||||
unsigned width, unsigned height, Bool selected)
|
||||
{
|
||||
WMScreen *scr = W_VIEW(tPtr)->screen;
|
||||
Display *dpy = scr->display;
|
||||
@@ -654,7 +654,7 @@ drawTab(TabView *tPtr, Drawable d, int x, int y,
|
||||
trap[7].y = y + height - (selected ? 0 : 1);
|
||||
|
||||
XFillPolygon(dpy, d, selected ? light : WMColorGC(tPtr->tabColor), trap, 8,
|
||||
Convex, CoordModeOrigin);
|
||||
Convex, CoordModeOrigin);
|
||||
|
||||
XDrawLine(dpy, d, white, trap[0].x, trap[0].y, trap[1].x, trap[1].y);
|
||||
XDrawLine(dpy, d, white, trap[1].x, trap[1].y, trap[2].x, trap[2].y);
|
||||
@@ -664,8 +664,8 @@ drawTab(TabView *tPtr, Drawable d, int x, int y,
|
||||
XDrawLine(dpy, d, black, trap[5].x, trap[5].y, trap[6].x, trap[6].y);
|
||||
XDrawLine(dpy, d, black, trap[6].x, trap[6].y, trap[7].x, trap[7].y);
|
||||
|
||||
XDrawLine(dpy, d, selected ? light : WMColorGC(scr->white),
|
||||
trap[0].x, trap[0].y, trap[7].x, trap[7].y);
|
||||
XDrawLine(dpy, d, selected ? light : WMColorGC(scr->white),
|
||||
trap[0].x, trap[0].y, trap[7].x, trap[7].y);
|
||||
}
|
||||
|
||||
|
||||
@@ -693,126 +693,126 @@ paintTabView(TabView *tPtr)
|
||||
int i;
|
||||
|
||||
if (tPtr->flags.type == WTTopTabsBevelBorder) {
|
||||
int count = tPtr->visibleTabs;
|
||||
int first = tPtr->firstVisible;
|
||||
int moreAtLeft;
|
||||
int moreAtRight;
|
||||
int selectedIsVisible;
|
||||
int ty;
|
||||
int twidth, theight;
|
||||
|
||||
ty = 2;
|
||||
theight = tPtr->tabHeight;
|
||||
|
||||
buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window,
|
||||
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);
|
||||
int count = tPtr->visibleTabs;
|
||||
int first = tPtr->firstVisible;
|
||||
int moreAtLeft;
|
||||
int moreAtRight;
|
||||
int selectedIsVisible;
|
||||
int ty;
|
||||
int twidth, theight;
|
||||
|
||||
if (tPtr->flags.dontFitAll) {
|
||||
moreAtLeft = first > 0;
|
||||
moreAtRight = (first + count) < tPtr->itemCount;
|
||||
if (tPtr->selectedItem >= first
|
||||
&& tPtr->selectedItem < first + count)
|
||||
selectedIsVisible = 1;
|
||||
else
|
||||
selectedIsVisible = 0;
|
||||
} else {
|
||||
moreAtLeft = 0;
|
||||
moreAtRight = 0;
|
||||
selectedIsVisible = 1;
|
||||
}
|
||||
ty = 2;
|
||||
theight = tPtr->tabHeight;
|
||||
|
||||
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]);
|
||||
buffer = XCreatePixmap(dpy, W_VIEW(tPtr)->window,
|
||||
W_VIEW(tPtr)->size.width, theight,
|
||||
W_VIEW(tPtr)->screen->depth);
|
||||
|
||||
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) {
|
||||
int idx = tPtr->selectedItem;
|
||||
XFillRectangle(dpy, buffer, WMColorGC(W_VIEW(tPtr)->backColor),
|
||||
0, 0, W_VIEW(tPtr)->size.width, tPtr->tabHeight);
|
||||
|
||||
drawTab(tPtr, buffer, positionOfTab(tPtr, idx),
|
||||
0, W_TabViewItemTabWidth(tPtr->items[idx]),
|
||||
theight, True);
|
||||
if (tPtr->flags.dontFitAll) {
|
||||
moreAtLeft = first > 0;
|
||||
moreAtRight = (first + count) < tPtr->itemCount;
|
||||
if (tPtr->selectedItem >= first
|
||||
&& tPtr->selectedItem < first + count)
|
||||
selectedIsVisible = 1;
|
||||
else
|
||||
selectedIsVisible = 0;
|
||||
} else {
|
||||
moreAtLeft = 0;
|
||||
moreAtRight = 0;
|
||||
selectedIsVisible = 1;
|
||||
}
|
||||
|
||||
XDrawLine(dpy, buffer, white, 0, theight - 1,
|
||||
positionOfTab(tPtr, idx), theight - 1);
|
||||
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]);
|
||||
|
||||
XDrawLine(dpy, buffer, white,
|
||||
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, theight - 1,
|
||||
W_VIEW_WIDTH(tPtr->view), theight - 1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
if (selectedIsVisible) {
|
||||
int idx = tPtr->selectedItem;
|
||||
|
||||
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,
|
||||
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, 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,
|
||||
tPtr->flags.enabled &&
|
||||
tPtr->items[first+i]->flags.enabled);
|
||||
}
|
||||
}
|
||||
|
||||
if (moreAtLeft) {
|
||||
paintDot(tPtr, buffer, 4, 10);
|
||||
paintDot(tPtr, buffer, 7, 10);
|
||||
paintDot(tPtr, buffer, 10, 10);
|
||||
}
|
||||
if (moreAtRight) {
|
||||
int x;
|
||||
|
||||
x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs);
|
||||
if (moreAtLeft) {
|
||||
paintDot(tPtr, buffer, 4, 10);
|
||||
paintDot(tPtr, buffer, 7, 10);
|
||||
paintDot(tPtr, buffer, 10, 10);
|
||||
}
|
||||
if (moreAtRight) {
|
||||
int x;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0,
|
||||
W_VIEW_WIDTH(tPtr->view), theight, 0, 0);
|
||||
x = positionOfTab(tPtr, tPtr->firstVisible + tPtr->visibleTabs);
|
||||
|
||||
XFreePixmap(dpy, buffer);
|
||||
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);
|
||||
}
|
||||
|
||||
XCopyArea(dpy, buffer, W_VIEW(tPtr)->window, scr->copyGC, 0, 0,
|
||||
W_VIEW_WIDTH(tPtr->view), theight, 0, 0);
|
||||
|
||||
XFreePixmap(dpy, buffer);
|
||||
}
|
||||
switch (tPtr->flags.type) {
|
||||
case WTTopTabsBevelBorder:
|
||||
drawRelief(scr, W_VIEW(tPtr)->window, 0, tPtr->tabHeight - 1,
|
||||
W_VIEW(tPtr)->size.width,
|
||||
W_VIEW(tPtr)->size.height - tPtr->tabHeight + 1);
|
||||
break;
|
||||
case WTTopTabsBevelBorder:
|
||||
drawRelief(scr, W_VIEW(tPtr)->window, 0, tPtr->tabHeight - 1,
|
||||
W_VIEW(tPtr)->size.width,
|
||||
W_VIEW(tPtr)->size.height - tPtr->tabHeight + 1);
|
||||
break;
|
||||
|
||||
case WTNoTabsBevelBorder:
|
||||
W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width,
|
||||
W_VIEW(tPtr)->size.height, WRRaised);
|
||||
break;
|
||||
case WTNoTabsBevelBorder:
|
||||
W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width,
|
||||
W_VIEW(tPtr)->size.height, WRRaised);
|
||||
break;
|
||||
|
||||
case WTNoTabsLineBorder:
|
||||
W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width,
|
||||
W_VIEW(tPtr)->size.height, WRSimple);
|
||||
break;
|
||||
case WTNoTabsLineBorder:
|
||||
W_DrawRelief(scr, W_VIEW(tPtr)->window, 0, 0, W_VIEW(tPtr)->size.width,
|
||||
W_VIEW(tPtr)->size.height, WRSimple);
|
||||
break;
|
||||
|
||||
case WTNoTabsNoBorder:
|
||||
break;
|
||||
case WTNoTabsNoBorder:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,19 +823,19 @@ rearrange(TabView *tPtr)
|
||||
int i;
|
||||
int width, height;
|
||||
int bordered = tPtr->flags.bordered;
|
||||
|
||||
|
||||
recalcTabWidth(tPtr);
|
||||
|
||||
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);
|
||||
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))
|
||||
paintTabView(tPtr);
|
||||
paintTabView(tPtr);
|
||||
}
|
||||
|
||||
|
||||
@@ -852,8 +852,8 @@ destroyTabView(TabView *tPtr)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < tPtr->itemCount; i++) {
|
||||
WMSetTabViewItemView(tPtr->items[i], NULL);
|
||||
WMDestroyTabViewItem(tPtr->items[i]);
|
||||
WMSetTabViewItemView(tPtr->items[i], NULL);
|
||||
WMDestroyTabViewItem(tPtr->items[i]);
|
||||
}
|
||||
wfree(tPtr->items);
|
||||
|
||||
@@ -880,11 +880,11 @@ W_DrawLabel(WMTabViewItem *item, Drawable d, WMRect rect, Bool enabled)
|
||||
WMScreen *scr = W_VIEW(item->tabView)->screen;
|
||||
|
||||
if (!item->label)
|
||||
return;
|
||||
return;
|
||||
|
||||
WMDrawString(scr, d, enabled ? scr->black : scr->darkGray,
|
||||
item->tabView->font, rect.pos.x, rect.pos.y,
|
||||
item->label, strlen(item->label));
|
||||
item->tabView->font, rect.pos.x, rect.pos.y,
|
||||
item->label, strlen(item->label));
|
||||
}
|
||||
|
||||
|
||||
@@ -971,7 +971,7 @@ WMSetTabViewItemEnabled(WMTabViewItem *tPtr, Bool flag)
|
||||
{
|
||||
tPtr->flags.enabled = ((flag==0) ? 0 : 1);
|
||||
if (tPtr->tabView && W_VIEW_REALIZED(tPtr->tabView->view))
|
||||
paintTabView(tPtr->tabView);
|
||||
paintTabView(tPtr->tabView);
|
||||
}
|
||||
|
||||
|
||||
@@ -986,7 +986,7 @@ void
|
||||
WMSetTabViewFont(WMTabView *tPtr, WMFont *font)
|
||||
{
|
||||
if (tPtr->font)
|
||||
WMReleaseFont(tPtr->font);
|
||||
WMReleaseFont(tPtr->font);
|
||||
|
||||
tPtr->font = WMRetainFont(font);
|
||||
tPtr->tabHeight = WMFontHeight(tPtr->font) + 3;
|
||||
@@ -998,15 +998,15 @@ void
|
||||
WMSetTabViewItemLabel(WMTabViewItem *item, char *label)
|
||||
{
|
||||
if (item->label)
|
||||
wfree(item->label);
|
||||
wfree(item->label);
|
||||
|
||||
if (label)
|
||||
item->label = wstrdup(label);
|
||||
item->label = wstrdup(label);
|
||||
else
|
||||
item->label = NULL;
|
||||
item->label = NULL;
|
||||
|
||||
if (item->tabView)
|
||||
recalcTabWidth(item->tabView);
|
||||
recalcTabWidth(item->tabView);
|
||||
}
|
||||
|
||||
|
||||
@@ -1035,10 +1035,11 @@ void
|
||||
WMDestroyTabViewItem(WMTabViewItem *item)
|
||||
{
|
||||
if (item->label)
|
||||
wfree(item->label);
|
||||
wfree(item->label);
|
||||
|
||||
if (item->view)
|
||||
W_DestroyView(item->view);
|
||||
W_DestroyView(item->view);
|
||||
|
||||
wfree(item);
|
||||
}
|
||||
|
||||
+659
-657
File diff suppressed because it is too large.
Load diff
+559
-559
File diff suppressed because it is too large.
Load diff
+273
-273
@@ -9,11 +9,11 @@
|
||||
typedef struct W_Window {
|
||||
W_Class widgetClass;
|
||||
W_View *view;
|
||||
|
||||
|
||||
struct W_Window *nextPtr; /* next in the window list */
|
||||
|
||||
struct W_Window *owner;
|
||||
|
||||
|
||||
char *title;
|
||||
|
||||
WMPixmap *miniImage; /* miniwindow */
|
||||
@@ -33,17 +33,17 @@ typedef struct W_Window {
|
||||
|
||||
WMAction *closeAction;
|
||||
void *closeData;
|
||||
|
||||
|
||||
int level;
|
||||
|
||||
struct {
|
||||
unsigned style:4;
|
||||
unsigned configured:1;
|
||||
unsigned documentEdited:1;
|
||||
unsigned style:4;
|
||||
unsigned configured:1;
|
||||
unsigned documentEdited:1;
|
||||
|
||||
unsigned setUPos:1;
|
||||
unsigned setPPos:1;
|
||||
unsigned setAspect:1;
|
||||
unsigned setAspect:1;
|
||||
} flags;
|
||||
} _Window;
|
||||
|
||||
@@ -82,10 +82,10 @@ static void willResizeWindow(W_ViewDelegate *, WMView *, unsigned*, unsigned*);
|
||||
|
||||
struct W_ViewDelegate _WindowViewDelegate = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
willResizeWindow
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
willResizeWindow
|
||||
};
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ static void handleEvents();
|
||||
|
||||
static void realizeWindow();
|
||||
|
||||
static void
|
||||
static void
|
||||
realizeObserver(void *self, WMNotification *not)
|
||||
{
|
||||
realizeWindow(self);
|
||||
@@ -111,7 +111,7 @@ WMWindow*
|
||||
WMCreatePanelWithStyleForWindow(WMWindow *owner, char *name, int style)
|
||||
{
|
||||
WMWindow *win;
|
||||
|
||||
|
||||
win = WMCreateWindowWithStyle(owner->view->screen, name, style);
|
||||
win->owner = owner;
|
||||
|
||||
@@ -122,11 +122,11 @@ WMCreatePanelWithStyleForWindow(WMWindow *owner, char *name, int style)
|
||||
|
||||
WMWindow*
|
||||
WMCreatePanelForWindow(WMWindow *owner, char *name)
|
||||
{
|
||||
return WMCreatePanelWithStyleForWindow(owner, name,
|
||||
WMTitledWindowMask
|
||||
|WMClosableWindowMask
|
||||
|WMResizableWindowMask);
|
||||
{
|
||||
return WMCreatePanelWithStyleForWindow(owner, name,
|
||||
WMTitledWindowMask
|
||||
|WMClosableWindowMask
|
||||
|WMResizableWindowMask);
|
||||
}
|
||||
|
||||
|
||||
@@ -134,10 +134,10 @@ void
|
||||
WMChangePanelOwner(WMWindow *win, WMWindow *newOwner)
|
||||
{
|
||||
win->owner = newOwner;
|
||||
|
||||
|
||||
if (win->view->flags.realized && newOwner) {
|
||||
XSetTransientForHint(win->view->screen->display, win->view->window,
|
||||
newOwner->view->window);
|
||||
XSetTransientForHint(win->view->screen->display, win->view->window,
|
||||
newOwner->view->window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,9 +147,9 @@ WMWindow*
|
||||
WMCreateWindow(WMScreen *screen, char *name)
|
||||
{
|
||||
return WMCreateWindowWithStyle(screen, name, WMTitledWindowMask
|
||||
|WMClosableWindowMask
|
||||
|WMMiniaturizableWindowMask
|
||||
|WMResizableWindowMask);
|
||||
|WMClosableWindowMask
|
||||
|WMMiniaturizableWindowMask
|
||||
|WMResizableWindowMask);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +166,8 @@ WMCreateWindowWithStyle(WMScreen *screen, char *name, int style)
|
||||
|
||||
win->view = W_CreateTopView(screen);
|
||||
if (!win->view) {
|
||||
wfree(win);
|
||||
return NULL;
|
||||
wfree(win);
|
||||
return NULL;
|
||||
}
|
||||
win->view->self = win;
|
||||
|
||||
@@ -180,13 +180,13 @@ WMCreateWindowWithStyle(WMScreen *screen, char *name, int style)
|
||||
screen->windowList = win;
|
||||
|
||||
WMCreateEventHandler(win->view, ExposureMask|StructureNotifyMask
|
||||
|ClientMessageMask|FocusChangeMask,
|
||||
handleEvents, win);
|
||||
|ClientMessageMask|FocusChangeMask,
|
||||
handleEvents, win);
|
||||
|
||||
W_ResizeView(win->view, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
|
||||
WMAddNotificationObserver(realizeObserver, win,
|
||||
WMViewRealizedNotification, win->view);
|
||||
WMViewRealizedNotification, win->view);
|
||||
|
||||
win->flags.style = style;
|
||||
|
||||
@@ -206,24 +206,24 @@ WMSetWindowTitle(WMWindow *win, char *title)
|
||||
int result;
|
||||
|
||||
if (win->title!=NULL)
|
||||
wfree(win->title);
|
||||
wfree(win->title);
|
||||
if (title!=NULL)
|
||||
win->title = wstrdup(title);
|
||||
win->title = wstrdup(title);
|
||||
else
|
||||
win->title = NULL;
|
||||
win->title = NULL;
|
||||
|
||||
if (win->view->flags.realized) {
|
||||
result = XmbTextListToTextProperty (win->view->screen->display,
|
||||
&title, 1, XStdICCTextStyle,
|
||||
&property);
|
||||
if (result == XNoMemory || result == XLocaleNotSupported) {
|
||||
wwarning("window title conversion error... using STRING encoding");
|
||||
XStoreName(win->view->screen->display, win->view->window, title);
|
||||
} else {
|
||||
XSetWMName(win->view->screen->display, win->view->window, &property);
|
||||
if (property.value)
|
||||
XFree(property.value);
|
||||
}
|
||||
result = XmbTextListToTextProperty (win->view->screen->display,
|
||||
&title, 1, XStdICCTextStyle,
|
||||
&property);
|
||||
if (result == XNoMemory || result == XLocaleNotSupported) {
|
||||
wwarning("window title conversion error... using STRING encoding");
|
||||
XStoreName(win->view->screen->display, win->view->window, title);
|
||||
} else {
|
||||
XSetWMName(win->view->screen->display, win->view->window, &property);
|
||||
if (property.value)
|
||||
XFree(property.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,64 +239,64 @@ WMSetWindowCloseAction(WMWindow *win, WMAction *action, void *clientData)
|
||||
WMScreen *scr = win->view->screen;
|
||||
|
||||
if (win->view->flags.realized) {
|
||||
if (action && !win->closeAction) {
|
||||
if (!XGetWMProtocols(scr->display, win->view->window, &atoms,
|
||||
&count)) {
|
||||
count = 0;
|
||||
}
|
||||
newAtoms = wmalloc((count+1)*sizeof(Atom));
|
||||
if (count > 0)
|
||||
memcpy(newAtoms, atoms, count*sizeof(Atom));
|
||||
newAtoms[count++] = scr->deleteWindowAtom;
|
||||
XSetWMProtocols(scr->display, win->view->window, newAtoms, count);
|
||||
if (atoms)
|
||||
XFree(atoms);
|
||||
wfree(newAtoms);
|
||||
} else if (!action && win->closeAction) {
|
||||
int i, ncount;
|
||||
|
||||
if (XGetWMProtocols(scr->display, win->view->window, &atoms,
|
||||
&count) && count>0) {
|
||||
newAtoms = wmalloc((count-1)*sizeof(Atom));
|
||||
ncount = 0;
|
||||
for (i=0; i < count; i++) {
|
||||
if (atoms[i]!=scr->deleteWindowAtom) {
|
||||
newAtoms[i] = atoms[i];
|
||||
ncount++;
|
||||
}
|
||||
}
|
||||
XSetWMProtocols(scr->display, win->view->window, newAtoms,
|
||||
ncount);
|
||||
if (atoms)
|
||||
XFree(atoms);
|
||||
wfree(newAtoms);
|
||||
}
|
||||
}
|
||||
if (action && !win->closeAction) {
|
||||
if (!XGetWMProtocols(scr->display, win->view->window, &atoms,
|
||||
&count)) {
|
||||
count = 0;
|
||||
}
|
||||
newAtoms = wmalloc((count+1)*sizeof(Atom));
|
||||
if (count > 0)
|
||||
memcpy(newAtoms, atoms, count*sizeof(Atom));
|
||||
newAtoms[count++] = scr->deleteWindowAtom;
|
||||
XSetWMProtocols(scr->display, win->view->window, newAtoms, count);
|
||||
if (atoms)
|
||||
XFree(atoms);
|
||||
wfree(newAtoms);
|
||||
} else if (!action && win->closeAction) {
|
||||
int i, ncount;
|
||||
|
||||
if (XGetWMProtocols(scr->display, win->view->window, &atoms,
|
||||
&count) && count>0) {
|
||||
newAtoms = wmalloc((count-1)*sizeof(Atom));
|
||||
ncount = 0;
|
||||
for (i=0; i < count; i++) {
|
||||
if (atoms[i]!=scr->deleteWindowAtom) {
|
||||
newAtoms[i] = atoms[i];
|
||||
ncount++;
|
||||
}
|
||||
}
|
||||
XSetWMProtocols(scr->display, win->view->window, newAtoms,
|
||||
ncount);
|
||||
if (atoms)
|
||||
XFree(atoms);
|
||||
wfree(newAtoms);
|
||||
}
|
||||
}
|
||||
}
|
||||
win->closeAction = action;
|
||||
win->closeData = clientData;
|
||||
win->closeData = clientData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
willResizeWindow(W_ViewDelegate *self, WMView *view,
|
||||
unsigned *width, unsigned *height)
|
||||
unsigned *width, unsigned *height)
|
||||
{
|
||||
WMWindow *win = (WMWindow*)view->self;
|
||||
|
||||
if (win->minSize.width > 0 && win->minSize.height > 0) {
|
||||
if (*width < win->minSize.width)
|
||||
*width = win->minSize.width;
|
||||
if (*height < win->minSize.height)
|
||||
*height = win->minSize.height;
|
||||
if (*width < win->minSize.width)
|
||||
*width = win->minSize.width;
|
||||
if (*height < win->minSize.height)
|
||||
*height = win->minSize.height;
|
||||
}
|
||||
|
||||
|
||||
if (win->maxSize.width > 0 && win->maxSize.height > 0) {
|
||||
if (*width > win->maxSize.width)
|
||||
*width = win->maxSize.width;
|
||||
if (*height > win->maxSize.height)
|
||||
*height = win->maxSize.height;
|
||||
if (*width > win->maxSize.width)
|
||||
*width = win->maxSize.width;
|
||||
if (*height > win->maxSize.height)
|
||||
*height = win->maxSize.height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,53 +308,53 @@ setSizeHints(WMWindow *win)
|
||||
|
||||
hints = XAllocSizeHints();
|
||||
if (!hints) {
|
||||
wwarning("could not allocate memory for window size hints");
|
||||
return;
|
||||
wwarning("could not allocate memory for window size hints");
|
||||
return;
|
||||
}
|
||||
|
||||
hints->flags = 0;
|
||||
|
||||
if (win->flags.setPPos) {
|
||||
hints->flags |= PPosition;
|
||||
hints->x = win->ppos.x;
|
||||
hints->y = win->ppos.y;
|
||||
hints->flags |= PPosition;
|
||||
hints->x = win->ppos.x;
|
||||
hints->y = win->ppos.y;
|
||||
}
|
||||
if (win->flags.setUPos) {
|
||||
hints->flags |= USPosition;
|
||||
hints->x = win->upos.x;
|
||||
hints->y = win->upos.y;
|
||||
hints->flags |= USPosition;
|
||||
hints->x = win->upos.x;
|
||||
hints->y = win->upos.y;
|
||||
}
|
||||
if (win->minSize.width>0 && win->minSize.height>0) {
|
||||
hints->flags |= PMinSize;
|
||||
hints->min_width = win->minSize.width;
|
||||
hints->min_height = win->minSize.height;
|
||||
hints->flags |= PMinSize;
|
||||
hints->min_width = win->minSize.width;
|
||||
hints->min_height = win->minSize.height;
|
||||
}
|
||||
if (win->maxSize.width>0 && win->maxSize.height>0) {
|
||||
hints->flags |= PMaxSize;
|
||||
hints->max_width = win->maxSize.width;
|
||||
hints->max_height = win->maxSize.height;
|
||||
hints->flags |= PMaxSize;
|
||||
hints->max_width = win->maxSize.width;
|
||||
hints->max_height = win->maxSize.height;
|
||||
}
|
||||
if (win->baseSize.width>0 && win->baseSize.height>0) {
|
||||
hints->flags |= PBaseSize;
|
||||
hints->base_width = win->baseSize.width;
|
||||
hints->base_height = win->baseSize.height;
|
||||
hints->flags |= PBaseSize;
|
||||
hints->base_width = win->baseSize.width;
|
||||
hints->base_height = win->baseSize.height;
|
||||
}
|
||||
if (win->resizeIncrement.width>0 && win->resizeIncrement.height>0) {
|
||||
hints->flags |= PResizeInc;
|
||||
hints->width_inc = win->resizeIncrement.width;
|
||||
hints->height_inc = win->resizeIncrement.height;
|
||||
hints->flags |= PResizeInc;
|
||||
hints->width_inc = win->resizeIncrement.width;
|
||||
hints->height_inc = win->resizeIncrement.height;
|
||||
}
|
||||
if (win->flags.setAspect) {
|
||||
hints->flags |= PAspect;
|
||||
hints->min_aspect.x = win->minAspect.x;
|
||||
hints->min_aspect.y = win->minAspect.y;
|
||||
hints->max_aspect.x = win->maxAspect.x;
|
||||
hints->max_aspect.y = win->maxAspect.y;
|
||||
hints->flags |= PAspect;
|
||||
hints->min_aspect.x = win->minAspect.x;
|
||||
hints->min_aspect.y = win->minAspect.y;
|
||||
hints->max_aspect.x = win->maxAspect.x;
|
||||
hints->max_aspect.y = win->maxAspect.y;
|
||||
}
|
||||
|
||||
|
||||
if (hints->flags) {
|
||||
XSetWMNormalHints(win->view->screen->display, win->view->window, hints);
|
||||
XSetWMNormalHints(win->view->screen->display, win->view->window, hints);
|
||||
}
|
||||
XFree(hints);
|
||||
}
|
||||
@@ -378,7 +378,7 @@ writeGNUstepWMAttr(WMScreen *scr, Window window, GNUstepWMAttributes *attr)
|
||||
data[7] = attr->close_mask;
|
||||
data[8] = attr->extra_flags;
|
||||
XChangeProperty(scr->display, window, scr->attribsAtom, scr->attribsAtom,
|
||||
32, PropModeReplace, (unsigned char *)data, 9);
|
||||
32, PropModeReplace, (unsigned char *)data, 9);
|
||||
}
|
||||
|
||||
|
||||
@@ -387,21 +387,21 @@ setWindowMakerHints(WMWindow *win)
|
||||
{
|
||||
GNUstepWMAttributes attribs;
|
||||
WMScreen *scr = WMWidgetScreen(win);
|
||||
|
||||
|
||||
memset(&attribs, 0, sizeof(GNUstepWMAttributes));
|
||||
attribs.flags = GSWindowStyleAttr|GSWindowLevelAttr|GSExtraFlagsAttr;
|
||||
attribs.window_style = win->flags.style;
|
||||
attribs.window_level = win->level;
|
||||
if (win->flags.documentEdited)
|
||||
attribs.extra_flags = GSDocumentEditedFlag;
|
||||
attribs.extra_flags = GSDocumentEditedFlag;
|
||||
else
|
||||
attribs.extra_flags = 0;
|
||||
attribs.extra_flags = 0;
|
||||
|
||||
writeGNUstepWMAttr(scr, win->view->window, &attribs);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static void
|
||||
realizeWindow(WMWindow *win)
|
||||
{
|
||||
XWMHints *hints;
|
||||
@@ -419,40 +419,40 @@ realizeWindow(WMWindow *win)
|
||||
hints = XAllocWMHints();
|
||||
hints->flags = 0;
|
||||
if (!scr->aflags.simpleApplication) {
|
||||
hints->flags |= WindowGroupHint;
|
||||
hints->window_group = scr->groupLeader;
|
||||
hints->flags |= WindowGroupHint;
|
||||
hints->window_group = scr->groupLeader;
|
||||
}
|
||||
if (win->miniImage) {
|
||||
hints->flags |= IconPixmapHint;
|
||||
hints->icon_pixmap = WMGetPixmapXID(win->miniImage);
|
||||
hints->icon_mask = WMGetPixmapMaskXID(win->miniImage);
|
||||
if (hints->icon_mask != None) {
|
||||
hints->flags |= IconMaskHint;
|
||||
}
|
||||
hints->flags |= IconPixmapHint;
|
||||
hints->icon_pixmap = WMGetPixmapXID(win->miniImage);
|
||||
hints->icon_mask = WMGetPixmapMaskXID(win->miniImage);
|
||||
if (hints->icon_mask != None) {
|
||||
hints->flags |= IconMaskHint;
|
||||
}
|
||||
}
|
||||
if (hints->flags != 0)
|
||||
XSetWMHints(scr->display, win->view->window, hints);
|
||||
XSetWMHints(scr->display, win->view->window, hints);
|
||||
XFree(hints);
|
||||
|
||||
count = 0;
|
||||
if (win->closeAction) {
|
||||
atoms[count++] = scr->deleteWindowAtom;
|
||||
atoms[count++] = scr->deleteWindowAtom;
|
||||
}
|
||||
|
||||
if (count>0)
|
||||
XSetWMProtocols(scr->display, win->view->window, atoms, count);
|
||||
XSetWMProtocols(scr->display, win->view->window, atoms, count);
|
||||
|
||||
if (win->title || win->miniTitle)
|
||||
XmbSetWMProperties(scr->display, win->view->window, win->title,
|
||||
win->miniTitle, NULL, 0, NULL, NULL, NULL);
|
||||
XmbSetWMProperties(scr->display, win->view->window, win->title,
|
||||
win->miniTitle, NULL, 0, NULL, NULL, NULL);
|
||||
|
||||
setWindowMakerHints(win);
|
||||
|
||||
setSizeHints(win);
|
||||
|
||||
if (win->owner) {
|
||||
XSetTransientForHint(scr->display, win->view->window,
|
||||
win->owner->view->window);
|
||||
XSetTransientForHint(scr->display, win->view->window,
|
||||
win->owner->view->window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ realizeWindow(WMWindow *win)
|
||||
|
||||
void
|
||||
WMSetWindowAspectRatio(WMWindow *win, int minX, int minY,
|
||||
int maxX, int maxY)
|
||||
int maxX, int maxY)
|
||||
{
|
||||
win->flags.setAspect = 1;
|
||||
win->minAspect.x = minX;
|
||||
@@ -480,7 +480,7 @@ WMSetWindowInitialPosition(WMWindow *win, int x, int y)
|
||||
win->ppos.x = x;
|
||||
win->ppos.y = y;
|
||||
if (win->view->flags.realized)
|
||||
setSizeHints(win);
|
||||
setSizeHints(win);
|
||||
WMMoveWidget(win, x, y);
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ WMSetWindowUserPosition(WMWindow *win, int x, int y)
|
||||
win->upos.x = x;
|
||||
win->upos.y = y;
|
||||
if (win->view->flags.realized)
|
||||
setSizeHints(win);
|
||||
setSizeHints(win);
|
||||
WMMoveWidget(win, x, y);
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ WMSetWindowMinSize(WMWindow *win, unsigned width, unsigned height)
|
||||
win->minSize.width = width;
|
||||
win->minSize.height = height;
|
||||
if (win->view->flags.realized)
|
||||
setSizeHints(win);
|
||||
setSizeHints(win);
|
||||
}
|
||||
|
||||
|
||||
@@ -517,7 +517,7 @@ WMSetWindowMaxSize(WMWindow *win, unsigned width, unsigned height)
|
||||
win->maxSize.width = width;
|
||||
win->maxSize.height = height;
|
||||
if (win->view->flags.realized)
|
||||
setSizeHints(win);
|
||||
setSizeHints(win);
|
||||
}
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ WMSetWindowBaseSize(WMWindow *win, unsigned width, unsigned height)
|
||||
win->baseSize.width = width;
|
||||
win->baseSize.height = height;
|
||||
if (win->view->flags.realized)
|
||||
setSizeHints(win);
|
||||
setSizeHints(win);
|
||||
}
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ WMSetWindowResizeIncrements(WMWindow *win, unsigned wIncr, unsigned hIncr)
|
||||
win->resizeIncrement.width = wIncr;
|
||||
win->resizeIncrement.height = hIncr;
|
||||
if (win->view->flags.realized)
|
||||
setSizeHints(win);
|
||||
setSizeHints(win);
|
||||
}
|
||||
|
||||
|
||||
@@ -547,7 +547,7 @@ WMSetWindowLevel(WMWindow *win, int level)
|
||||
{
|
||||
win->level = level;
|
||||
if (win->view->flags.realized)
|
||||
setWindowMakerHints(win);
|
||||
setWindowMakerHints(win);
|
||||
}
|
||||
|
||||
|
||||
@@ -556,9 +556,9 @@ WMSetWindowDocumentEdited(WMWindow *win, Bool flag)
|
||||
{
|
||||
flag = ((flag==0) ? 0 : 1);
|
||||
if (win->flags.documentEdited != flag) {
|
||||
win->flags.documentEdited = flag;
|
||||
if (win->view->flags.realized)
|
||||
setWindowMakerHints(win);
|
||||
win->flags.documentEdited = flag;
|
||||
if (win->view->flags.realized)
|
||||
setWindowMakerHints(win);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,37 +567,37 @@ void
|
||||
WMSetWindowMiniwindowPixmap(WMWindow *win, WMPixmap *pixmap)
|
||||
{
|
||||
if ((win->miniImage && !pixmap) || (!win->miniImage && pixmap)) {
|
||||
if (win->miniImage)
|
||||
WMReleasePixmap(win->miniImage);
|
||||
if (win->miniImage)
|
||||
WMReleasePixmap(win->miniImage);
|
||||
|
||||
if (pixmap)
|
||||
win->miniImage = WMRetainPixmap(pixmap);
|
||||
else
|
||||
win->miniImage = NULL;
|
||||
if (pixmap)
|
||||
win->miniImage = WMRetainPixmap(pixmap);
|
||||
else
|
||||
win->miniImage = NULL;
|
||||
|
||||
if (win->view->flags.realized) {
|
||||
XWMHints *hints;
|
||||
|
||||
hints = XGetWMHints(win->view->screen->display, win->view->window);
|
||||
if (!hints) {
|
||||
hints = XAllocWMHints();
|
||||
if (!hints) {
|
||||
wwarning("could not allocate memory for WM hints");
|
||||
return;
|
||||
}
|
||||
hints->flags = 0;
|
||||
}
|
||||
if (pixmap) {
|
||||
hints->flags |= IconPixmapHint;
|
||||
hints->icon_pixmap = WMGetPixmapXID(pixmap);
|
||||
hints->icon_mask = WMGetPixmapMaskXID(pixmap);
|
||||
if (hints->icon_mask != None) {
|
||||
hints->flags |= IconMaskHint;
|
||||
}
|
||||
}
|
||||
XSetWMHints(win->view->screen->display, win->view->window, hints);
|
||||
XFree(hints);
|
||||
}
|
||||
if (win->view->flags.realized) {
|
||||
XWMHints *hints;
|
||||
|
||||
hints = XGetWMHints(win->view->screen->display, win->view->window);
|
||||
if (!hints) {
|
||||
hints = XAllocWMHints();
|
||||
if (!hints) {
|
||||
wwarning("could not allocate memory for WM hints");
|
||||
return;
|
||||
}
|
||||
hints->flags = 0;
|
||||
}
|
||||
if (pixmap) {
|
||||
hints->flags |= IconPixmapHint;
|
||||
hints->icon_pixmap = WMGetPixmapXID(pixmap);
|
||||
hints->icon_mask = WMGetPixmapMaskXID(pixmap);
|
||||
if (hints->icon_mask != None) {
|
||||
hints->flags |= IconMaskHint;
|
||||
}
|
||||
}
|
||||
XSetWMHints(win->view->screen->display, win->view->window, hints);
|
||||
XFree(hints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,30 +609,30 @@ WMSetWindowMiniwindowTitle(WMWindow *win, char *title)
|
||||
int result;
|
||||
|
||||
if ((win->miniTitle && !title) || (!win->miniTitle && title)
|
||||
|| (title && win->miniTitle && strcoll(title, win->miniTitle)!=0)) {
|
||||
if (win->miniTitle)
|
||||
wfree(win->miniTitle);
|
||||
|
||||
if (title)
|
||||
win->miniTitle = wstrdup(title);
|
||||
else
|
||||
win->miniTitle = NULL;
|
||||
|| (title && win->miniTitle && strcoll(title, win->miniTitle)!=0)) {
|
||||
if (win->miniTitle)
|
||||
wfree(win->miniTitle);
|
||||
|
||||
if (win->view->flags.realized) {
|
||||
result = XmbTextListToTextProperty (win->view->screen->display,
|
||||
&title, 1, XStdICCTextStyle,
|
||||
&property);
|
||||
if (result == XNoMemory || result == XLocaleNotSupported) {
|
||||
wwarning("icon title conversion error..using STRING encoding");
|
||||
XSetIconName(win->view->screen->display, win->view->window,
|
||||
title);
|
||||
} else {
|
||||
XSetWMIconName(win->view->screen->display, win->view->window,
|
||||
&property);
|
||||
if (property.value)
|
||||
XFree(property.value);
|
||||
}
|
||||
}
|
||||
if (title)
|
||||
win->miniTitle = wstrdup(title);
|
||||
else
|
||||
win->miniTitle = NULL;
|
||||
|
||||
if (win->view->flags.realized) {
|
||||
result = XmbTextListToTextProperty (win->view->screen->display,
|
||||
&title, 1, XStdICCTextStyle,
|
||||
&property);
|
||||
if (result == XNoMemory || result == XLocaleNotSupported) {
|
||||
wwarning("icon title conversion error..using STRING encoding");
|
||||
XSetIconName(win->view->screen->display, win->view->window,
|
||||
title);
|
||||
} else {
|
||||
XSetWMIconName(win->view->screen->display, win->view->window,
|
||||
&property);
|
||||
if (property.value)
|
||||
XFree(property.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,8 +643,8 @@ WMCloseWindow(WMWindow *win)
|
||||
WMUnmapWidget(win);
|
||||
/* withdraw the window */
|
||||
if (win->view->flags.realized)
|
||||
XWithdrawWindow(win->view->screen->display, win->view->window,
|
||||
win->view->screen->screen);
|
||||
XWithdrawWindow(win->view->screen->display, win->view->window,
|
||||
win->view->screen->screen);
|
||||
}
|
||||
|
||||
|
||||
@@ -653,65 +653,65 @@ handleEvents(XEvent *event, void *clientData)
|
||||
{
|
||||
_Window *win = (_Window*)clientData;
|
||||
W_View *view = win->view;
|
||||
|
||||
|
||||
|
||||
|
||||
switch (event->type) {
|
||||
case ClientMessage:
|
||||
if (event->xclient.message_type == win->view->screen->protocolsAtom
|
||||
&& event->xclient.format == 32
|
||||
&& event->xclient.data.l[0]==win->view->screen->deleteWindowAtom) {
|
||||
|
||||
if (win->closeAction) {
|
||||
(*win->closeAction)(win, win->closeData);
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
case ConfigureNotify:
|
||||
if (event->xconfigure.width != view->size.width
|
||||
|| event->xconfigure.height != view->size.height) {
|
||||
case ClientMessage:
|
||||
if (event->xclient.message_type == win->view->screen->protocolsAtom
|
||||
&& event->xclient.format == 32
|
||||
&& event->xclient.data.l[0]==win->view->screen->deleteWindowAtom) {
|
||||
|
||||
view->size.width = event->xconfigure.width;
|
||||
view->size.height = event->xconfigure.height;
|
||||
if (win->closeAction) {
|
||||
(*win->closeAction)(win, win->closeData);
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
if (view->flags.notifySizeChanged) {
|
||||
WMPostNotificationName(WMViewSizeDidChangeNotification,
|
||||
view, NULL);
|
||||
}
|
||||
}
|
||||
if (event->xconfigure.x != view->pos.x
|
||||
|| event->xconfigure.y != view->pos.y) {
|
||||
*/
|
||||
case DestroyNotify:
|
||||
destroyWindow(win);
|
||||
break;
|
||||
|
||||
if (event->xconfigure.send_event) {
|
||||
view->pos.x = event->xconfigure.x;
|
||||
view->pos.y = event->xconfigure.y;
|
||||
} else {
|
||||
Window foo;
|
||||
case ConfigureNotify:
|
||||
if (event->xconfigure.width != view->size.width
|
||||
|| event->xconfigure.height != view->size.height) {
|
||||
|
||||
XTranslateCoordinates(view->screen->display,
|
||||
view->window, view->screen->rootWin,
|
||||
event->xconfigure.x, event->xconfigure.y,
|
||||
&view->pos.x, &view->pos.y, &foo);
|
||||
}
|
||||
}
|
||||
break;
|
||||
view->size.width = event->xconfigure.width;
|
||||
view->size.height = event->xconfigure.height;
|
||||
|
||||
if (view->flags.notifySizeChanged) {
|
||||
WMPostNotificationName(WMViewSizeDidChangeNotification,
|
||||
view, NULL);
|
||||
}
|
||||
}
|
||||
if (event->xconfigure.x != view->pos.x
|
||||
|| event->xconfigure.y != view->pos.y) {
|
||||
|
||||
if (event->xconfigure.send_event) {
|
||||
view->pos.x = event->xconfigure.x;
|
||||
view->pos.y = event->xconfigure.y;
|
||||
} else {
|
||||
Window foo;
|
||||
|
||||
XTranslateCoordinates(view->screen->display,
|
||||
view->window, view->screen->rootWin,
|
||||
event->xconfigure.x, event->xconfigure.y,
|
||||
&view->pos.x, &view->pos.y, &foo);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,38 +724,38 @@ destroyWindow(_Window *win)
|
||||
WMScreen *scr = win->view->screen;
|
||||
|
||||
WMRemoveNotificationObserver(win);
|
||||
|
||||
|
||||
if (scr->windowList == win) {
|
||||
scr->windowList = scr->windowList->nextPtr;
|
||||
scr->windowList = scr->windowList->nextPtr;
|
||||
} else {
|
||||
WMWindow *ptr;
|
||||
ptr = scr->windowList;
|
||||
|
||||
if (ptr) {
|
||||
while (ptr->nextPtr) {
|
||||
if (ptr->nextPtr==win) {
|
||||
ptr->nextPtr = ptr->nextPtr->nextPtr;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->nextPtr;
|
||||
}
|
||||
}
|
||||
WMWindow *ptr;
|
||||
ptr = scr->windowList;
|
||||
|
||||
if (ptr) {
|
||||
while (ptr->nextPtr) {
|
||||
if (ptr->nextPtr==win) {
|
||||
ptr->nextPtr = ptr->nextPtr->nextPtr;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->nextPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (win->title) {
|
||||
wfree(win->title);
|
||||
wfree(win->title);
|
||||
}
|
||||
|
||||
|
||||
if (win->miniTitle) {
|
||||
wfree(win->miniTitle);
|
||||
wfree(win->miniTitle);
|
||||
}
|
||||
|
||||
|
||||
if (win->miniImage) {
|
||||
WMReleasePixmap(win->miniImage);
|
||||
WMReleasePixmap(win->miniImage);
|
||||
}
|
||||
|
||||
|
||||
if (win->wname)
|
||||
wfree(win->wname);
|
||||
wfree(win->wname);
|
||||
|
||||
wfree(win);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user