*** PixEdit.c.orig Fri Aug 30 09:16:34 1996 --- PixEdit.c Fri Aug 30 09:16:35 1996 *************** *** 1,5 **** /* ! * $Id: PixEdit.c,v 1.16 1996/08/19 12:38:21 lmallet Exp $ * * Copyright (c) 1991-1994 Lionel MALLET * --- 1,5 ---- /* ! * $Id: PixEdit.c,v 1.19 1996/08/30 11:03:24 lmallet Exp $ * * Copyright (c) 1991-1994 Lionel MALLET * *************** *** 55,61 **** * Author: Davor Matic, MIT X Consortium */ ! static char rcsid[] = "$Id: PixEdit.c,v 1.16 1996/08/19 12:38:21 lmallet Exp $"; #include --- 55,61 ---- * Author: Davor Matic, MIT X Consortium */ ! static char rcsid[] = "$Id: PixEdit.c,v 1.19 1996/08/30 11:03:24 lmallet Exp $"; #include *************** *** 79,84 **** --- 79,87 ---- #include #endif /* NO_EDITRES */ #define CHARSET XmSTRING_DEFAULT_CHARSET + #if XmVersion > 1001 /* Motif 1.2 or > */ + #include + #endif #else /* USE_ATHENA */ #include #include *************** *** 96,101 **** --- 99,106 ---- #include "Pixmap.h" #include "Version.h" + #include "patchlevel.h" + static char *info_str = NULL; #define TOGGLE True #define BUTTON False *************** *** 343,360 **** Colormap cmap; Pixel black, white; - /* picked up from rgb.c of Xpm lib */ - #ifndef UNUSE_XPM - typedef struct { /* rgb values and ascii names (from rgb text file) */ - int r, g, b; /* rgb values, range of 0 -> 65535 */ - char *name; /* color mnemonic of rgb value */ - } RgbName; - #define MAX_RGBNAMES 1024 - #endif /* UNUSE_XPM */ - RgbName rgb_table[MAX_RGBNAMES]; - - int max_ncolors; - char *colorInMenu; char *hints_cmt, *colors_cmt, *pixels_cmt; PWColorInfo **colorTable; --- 348,353 ---- *************** *** 364,372 **** String filename = NULL, format = ""; char message[80]; - extern int xpmReadRgbNames(); - extern char *xpmGetRgbName(); - void FixMenu(), SwitchImage(), SwitchGrid(), SwitchAxes(), SwitchProportional(), SwitchZoom(), DoLoad(), DoInsert(), DoSave(), DoSaveAs(), DoResize(), DoRescale(), DoFilename(), DoHintsCmt(), --- 357,362 ---- *************** *** 472,542 **** { Widget wi; int max_colors = 1<= max_colors)) printf( "Warning: Color pixel %d out of bounds for display (pixel range [0->%d]\n", pixel, max_colors-1); ! else if (colorInMenu[index] == 0) { int *id = (int *)XtMalloc(sizeof(int)); - char *menu_name; - XColor color; Arg wargs[1]; - Boolean no_name = False; *id = pixel + Color_offset; - colorInMenu[index] = '1'; /* Two kinds of colors: not transparent and transparent */ if (pixel != TRANSPARENT(dpy, screen)) { - color.pixel = pixel; - XQueryColor(dpy, cmap, &color); - #ifndef USE_ATHENA XtSetArg(wargs[0], XmNbackground, pixel); #else /* USE_ATHENA */ XtSetArg(wargs[0], XtNbackground, pixel); #endif /* USE_ATHENA */ - if (!name) - { - if (!(menu_name = xpmGetRgbName(rgb_table, max_ncolors, - (int) color.red, - (int) color.green, - (int)color.blue))) - { - no_name = True; - menu_name = (char *) XtMalloc(15*sizeof(char)); - sprintf(menu_name, "#%04X%04X%04X", - color.red, color.green, color.blue); - } - } - else menu_name = name; - #ifdef DEBUG printf("Adding color %d %s to menu\n", pixel, name); #endif /* DEBUG */ - if ((color.red != 0) || (color.green != 0) || (color.blue != 0) || - (color.pixel == black)) - { #ifndef USE_ATHENA ! wi = (Widget)XmCreatePushButton(color_pane_widget, menu_name, ! wargs, 1); ! XtAddCallback(wi, XmNactivateCallback, TheCallback, id); ! XtManageChild(wi); ! #else /* USE_ATHENA */ ! wi = XtCreateManagedWidget(menu_name, commandWidgetClass, ! color_pane_widget, wargs, 1); ! XtAddCallback(wi, XtNcallback, TheCallback, id); #endif /* USE_ATHENA */ - } - - if (no_name) XtFree(menu_name); } else if (pixel == TRANSPARENT(dpy, screen)) { --- 462,502 ---- { Widget wi; int max_colors = 1<= max_colors)) printf( "Warning: Color pixel %d out of bounds for display (pixel range [0->%d]\n", pixel, max_colors-1); ! else { int *id = (int *)XtMalloc(sizeof(int)); Arg wargs[1]; *id = pixel + Color_offset; /* Two kinds of colors: not transparent and transparent */ if (pixel != TRANSPARENT(dpy, screen)) { #ifndef USE_ATHENA XtSetArg(wargs[0], XmNbackground, pixel); #else /* USE_ATHENA */ XtSetArg(wargs[0], XtNbackground, pixel); #endif /* USE_ATHENA */ #ifdef DEBUG printf("Adding color %d %s to menu\n", pixel, name); #endif /* DEBUG */ #ifndef USE_ATHENA ! wi = (Widget)XmCreatePushButton(color_pane_widget, name, ! wargs, 1); ! XtAddCallback(wi, XmNactivateCallback, TheCallback, id); ! XtManageChild(wi); ! #else /* USE_ATHENA */ ! wi = XtCreateManagedWidget(name, commandWidgetClass, ! color_pane_widget, wargs, 1); ! XtAddCallback(wi, XtNcallback, TheCallback, id); #endif /* USE_ATHENA */ } else if (pixel == TRANSPARENT(dpy, screen)) { *************** *** 556,564 **** #endif /* USE_ATHENA */ } } - #ifdef DEBUG - else printf("Already used color!\n"); - #endif /* DEBUG */ } --- 516,521 ---- *************** *** 723,730 **** Arg wargs[2]; String str; #ifndef USE_ATHENA ! char fname[256], *fn = fname; ! char size[50]; XmString xmstr; #endif /* USE_ATHENA */ --- 680,686 ---- Arg wargs[2]; String str; #ifndef USE_ATHENA ! char *fn; XmString xmstr; #endif /* USE_ATHENA */ *************** *** 732,745 **** n = 0; #ifndef USE_ATHENA ! while ((*str != ' ') || (*(str-1) == ':')) *fn++ = *str++; ! *fn = 0; ! strcpy(size, str); ! xmstr = XmStringCreateLtoR(fname, XmSTRING_DEFAULT_CHARSET); XtSetArg(wargs[n], XmNlabelString, xmstr); n++; XtSetValues(status_widget, wargs, n); XmStringFree(xmstr); ! xmstr = XmStringCreateLtoR(size, XmSTRING_DEFAULT_CHARSET); XtSetArg(wargs[n], XmNlabelString, xmstr); n++; XtSetValues(statusb_widget, wargs, n); XmStringFree(xmstr); --- 688,703 ---- n = 0; #ifndef USE_ATHENA ! fn = str; ! while ((*str != ' ') || (*(str-1) == ':')) str++; ! *str = 0; ! xmstr = XmStringCreateLtoR(fn, XmSTRING_DEFAULT_CHARSET); XtSetArg(wargs[n], XmNlabelString, xmstr); n++; XtSetValues(status_widget, wargs, n); XmStringFree(xmstr); ! *str++ = ' '; ! n = 0; ! xmstr = XmStringCreateLtoR(str, XmSTRING_DEFAULT_CHARSET); XtSetArg(wargs[n], XmNlabelString, xmstr); n++; XtSetValues(statusb_widget, wargs, n); XmStringFree(xmstr); *************** *** 755,774 **** { Widget colorButton; Arg wargs[1]; ! /* index in colorTable is 0 for transparent, pixel+1 for other colors */ ! int index = (current == TRANSPARENT(dpy, screen) ? 0 : current + 1); #ifndef USE_ATHENA XmString xmstr; #endif /* USE_ATHENA */ current_color = current; ! colorTable = PWGetColorTable(w); #ifndef USE_ATHENA ! xmstr = XmStringCreateLtoR(colorTable[index]->c_name, CHARSET); XtSetArg(wargs[0], XmNlabelString, xmstr); #else /* USE_ATHENA */ ! XtSetArg(wargs[0], XtNlabel, colorTable[index]->c_name); #endif /* USE_ATHENA */ colorButton = XtNameToWidget( formy_widget, "colorButton" ); --- 713,731 ---- { Widget colorButton; Arg wargs[1]; ! PWColorInfo *color; #ifndef USE_ATHENA XmString xmstr; #endif /* USE_ATHENA */ current_color = current; ! color = PWGetColor(w, current); #ifndef USE_ATHENA ! xmstr = XmStringCreateLtoR(color->c_name, CHARSET); XtSetArg(wargs[0], XmNlabelString, xmstr); #else /* USE_ATHENA */ ! XtSetArg(wargs[0], XtNlabel, color->c_name); #endif /* USE_ATHENA */ colorButton = XtNameToWidget( formy_widget, "colorButton" ); *************** *** 1299,1328 **** if (PopupDialog(input_dialog, "Color name (name or #rgb) to add:", "", &cname, XtGrabExclusive) == Okay) { ! XColor color; ! if ((!XParseColor(dpy, cmap, cname, &color)) || ! (!XAllocColor(dpy, cmap, &color))) { fprintf(stderr, "Warning: color %s could not be parsed/allocated!", cname); } ! else { ! colorToAdd(pixmap_widget, color.pixel, ! ((cname[0] == '#') ? ! xpmGetRgbName(rgb_table, max_ncolors, ! (int) color.red, ! (int) color.green, ! (int) color.blue) : cname)); ! PWUseColorInTable(pixmap_widget, color.pixel, NULL, NULL, NULL, ! NULL, NULL, ! ((cname[0] == '#') ? ! xpmGetRgbName(rgb_table, max_ncolors, ! (int) color.red, ! (int) color.green, ! (int) color.blue) : cname)); } } } --- 1256,1274 ---- if (PopupDialog(input_dialog, "Color name (name or #rgb) to add:", "", &cname, XtGrabExclusive) == Okay) { ! XColor xcolor; ! if ((!XParseColor(dpy, cmap, cname, &xcolor)) || ! (!XAllocColor(dpy, cmap, &xcolor))) { fprintf(stderr, "Warning: color %s could not be parsed/allocated!", cname); } ! else if (PWGetColor(pixmap_widget, xcolor.pixel) == NULL) { ! PWUseColorInTable(pixmap_widget, xcolor.pixel, NULL, NULL, NULL, ! NULL, NULL, cname); } } } *************** *** 1331,1378 **** { char *s_name; char message[80]; ! /* index in colorTable is 0 for transparent, pixel+1 for other colors */ ! int index = (current_color == TRANSPARENT(dpy, screen) ? 0 : current_color + 1); - colorTable = PWGetColorTable(pixmap_widget); sprintf(message, "Color `%s' [%d] symbolic name:", ! colorTable[index]->c_name, current_color); if (PopupDialog(input_dialog, message, ! (colorTable[index]->s_name ? ! colorTable[index]->s_name : ""), &s_name, XtGrabExclusive) == Okay) PWUpdateColorInTable(pixmap_widget, current_color, ! colorTable[index]->symbol, s_name, ! colorTable[index]->m_name, ! colorTable[index]->g4_name, ! colorTable[index]->g_name, ! colorTable[index]->c_name); } void DoMonochromeName() { char *m_name; char message[80]; ! /* index in colorTable is 0 for transparent, pixel+1 for other colors */ ! int index = (current_color == TRANSPARENT(dpy, screen) ? 0 : current_color + 1); - colorTable = PWGetColorTable(pixmap_widget); sprintf(message, "Color `%s' [%d] monochrome display name:", ! colorTable[index]->c_name, current_color); if (PopupDialog(input_dialog, message, ! (colorTable[index]->m_name ? ! colorTable[index]->m_name : ""), &m_name, XtGrabExclusive) == Okay) { ! XColor color; ! if (!XParseColor(dpy, cmap, m_name, &color)) { fprintf(stderr, "Warning: color %s could not be parsed!\n", m_name); --- 1277,1318 ---- { char *s_name; char message[80]; ! PWColorInfo *color = PWGetColor(pixmap_widget, current_color); sprintf(message, "Color `%s' [%d] symbolic name:", ! color->c_name, current_color); if (PopupDialog(input_dialog, message, ! (color->s_name ? color->s_name : ""), &s_name, XtGrabExclusive) == Okay) PWUpdateColorInTable(pixmap_widget, current_color, ! color->symbol, s_name, ! color->m_name, ! color->g4_name, ! color->g_name, ! color->c_name); } void DoMonochromeName() { char *m_name; char message[80]; ! PWColorInfo *color = PWGetColor(pixmap_widget, current_color); sprintf(message, "Color `%s' [%d] monochrome display name:", ! color->c_name, current_color); if (PopupDialog(input_dialog, message, ! (color->m_name ? color->m_name : ""), &m_name, XtGrabExclusive) == Okay) { ! XColor xcolor; ! if (!XParseColor(dpy, cmap, m_name, &xcolor)) { fprintf(stderr, "Warning: color %s could not be parsed!\n", m_name); *************** *** 1380,1391 **** else PWUpdateColorInTable(pixmap_widget, current_color, ! colorTable[index]->symbol, ! colorTable[index]->s_name, m_name, ! colorTable[index]->g4_name, ! colorTable[index]->g_name, ! colorTable[index]->c_name); } } --- 1320,1331 ---- else PWUpdateColorInTable(pixmap_widget, current_color, ! color->symbol, ! color->s_name, m_name, ! color->g4_name, ! color->g_name, ! color->c_name); } } *************** *** 1393,1414 **** { char *g4_name; char message[80]; ! /* index in colorTable is 0 for transparent, pixel+1 for other colors */ ! int index = (current_color == TRANSPARENT(dpy, screen) ? 0 : current_color + 1); - colorTable = PWGetColorTable(pixmap_widget); sprintf(message, "Color `%s' [%d] grey scale 4 display name:", ! colorTable[index]->c_name, current_color); if (PopupDialog(input_dialog, message, ! (colorTable[index]->g4_name ? ! colorTable[index]->g4_name : ""), &g4_name, XtGrabExclusive) == Okay) { ! XColor color; ! if (!XParseColor(dpy, cmap, g4_name, &color)) { fprintf(stderr, "Warning: color %s could not be parsed!\n", g4_name); --- 1333,1351 ---- { char *g4_name; char message[80]; ! PWColorInfo *color = PWGetColor(pixmap_widget, current_color); sprintf(message, "Color `%s' [%d] grey scale 4 display name:", ! color->c_name, current_color); if (PopupDialog(input_dialog, message, ! (color->g4_name ? color->g4_name : ""), &g4_name, XtGrabExclusive) == Okay) { ! XColor xcolor; ! if (!XParseColor(dpy, cmap, g4_name, &xcolor)) { fprintf(stderr, "Warning: color %s could not be parsed!\n", g4_name); *************** *** 1416,1427 **** else PWUpdateColorInTable(pixmap_widget, current_color, ! colorTable[index]->symbol, ! colorTable[index]->s_name, ! colorTable[index]->m_name, g4_name, ! colorTable[index]->g_name, ! colorTable[index]->c_name); } } --- 1353,1364 ---- else PWUpdateColorInTable(pixmap_widget, current_color, ! color->symbol, ! color->s_name, ! color->m_name, g4_name, ! color->g_name, ! color->c_name); } } *************** *** 1429,1450 **** { char *g_name; char message[80]; ! /* index in colorTable is 0 for transparent, pixel+1 for other colors */ ! int index = (current_color == TRANSPARENT(dpy, screen) ? 0 : current_color + 1); ! ! colorTable = PWGetColorTable(pixmap_widget); sprintf(message, "Color `%s' [%d] grey scale display name:", ! colorTable[index]->c_name, current_color); if (PopupDialog(input_dialog, message, ! (colorTable[index]->g_name ? ! colorTable[index]->g_name : ""), &g_name, XtGrabExclusive) == Okay) { ! XColor color; ! if (!XParseColor(dpy, cmap, g_name, &color)) { fprintf(stderr, "Warning: color %s could not be parsed!\n", g_name); --- 1366,1384 ---- { char *g_name; char message[80]; ! PWColorInfo *color = PWGetColor(pixmap_widget, current_color); ! sprintf(message, "Color `%s' [%d] grey scale display name:", ! color->c_name, current_color); if (PopupDialog(input_dialog, message, ! (color->g_name ? color->g_name : ""), &g_name, XtGrabExclusive) == Okay) { ! XColor xcolor; ! if (!XParseColor(dpy, cmap, g_name, &xcolor)) { fprintf(stderr, "Warning: color %s could not be parsed!\n", g_name); *************** *** 1452,1463 **** else PWUpdateColorInTable(pixmap_widget, current_color, ! colorTable[index]->symbol, ! colorTable[index]->s_name, ! colorTable[index]->m_name, ! colorTable[index]->g4_name, g_name, ! colorTable[index]->c_name); } } --- 1386,1397 ---- else PWUpdateColorInTable(pixmap_widget, current_color, ! color->symbol, ! color->s_name, ! color->m_name, ! color->g4_name, g_name, ! color->c_name); } } *************** *** 1465,1484 **** { char *c_name; char message[80]; ! /* index in colorTable is 0 for transparent, pixel+1 for other colors */ ! int index = (current_color == TRANSPARENT(dpy, screen) ? 0 : current_color + 1); ! ! colorTable = PWGetColorTable(pixmap_widget); sprintf(message, "Color `%s' [%d] color display name:", ! colorTable[index]->c_name, current_color); /* RetryColorCname: */ if ((PopupDialog(input_dialog, message, ! (colorTable[index]->c_name ? ! colorTable[index]->c_name : ""), &c_name, XtGrabExclusive) == Okay) && (c_name)) { ! XColor color; /* if (strcasecmp(c_name, NoColorName) == 0) { --- 1399,1415 ---- { char *c_name; char message[80]; ! PWColorInfo *color = PWGetColor(pixmap_widget, current_color); ! sprintf(message, "Color `%s' [%d] color display name:", ! color->c_name, current_color); /* RetryColorCname: */ if ((PopupDialog(input_dialog, message, ! (color->c_name ? color->c_name : ""), &c_name, XtGrabExclusive) == Okay) && (c_name)) { ! XColor xcolor; /* if (strcasecmp(c_name, NoColorName) == 0) { *************** *** 1487,1507 **** goto RetryColorCname; } else*/ if ((strcasecmp(c_name, NoColorName) != 0) && ! (!XParseColor(dpy, cmap, c_name, &color))) { fprintf(stderr, "Warning: color %s could not be parsed!\n", c_name); } else { ! FixColorMenuLabel(colorTable[index]->c_name, c_name); PWUpdateColorInTable(pixmap_widget, current_color, ! colorTable[index]->symbol, ! colorTable[index]->s_name, ! colorTable[index]->m_name, ! colorTable[index]->g4_name, ! colorTable[index]->g_name, c_name); } } --- 1418,1438 ---- goto RetryColorCname; } else*/ if ((strcasecmp(c_name, NoColorName) != 0) && ! (!XParseColor(dpy, cmap, c_name, &xcolor))) { fprintf(stderr, "Warning: color %s could not be parsed!\n", c_name); } else { ! FixColorMenuLabel(color->c_name, c_name); PWUpdateColorInTable(pixmap_widget, current_color, ! color->symbol, ! color->s_name, ! color->m_name, ! color->g4_name, ! color->g_name, c_name); } } *************** *** 1712,1718 **** void InfoCallback() { ! PopupDialog(info_dialog, info, NULL, NULL, XtGrabExclusive); } --- 1643,1655 ---- void InfoCallback() { ! if (info_str == NULL) ! { ! info_str = XtMalloc((strlen(info) + 1) * sizeof(char)); ! sprintf(info_str, info, PATCHLEVEL); ! } ! ! PopupDialog(info_dialog, info_str, NULL, NULL, XtGrabExclusive); } *************** *** 1803,1813 **** char filename[256]; - /* load transparent color */ - colorToAdd(pixmap_widget, TRANSPARENT(dpy, screen), NoColorName); - PWUseColorInTable(pixmap_widget, TRANSPARENT(dpy, screen), - NULL, NoColorName, NULL, NULL, NULL, NoColorName); - /* first try to open in local dir */ if (!(colorfile = fopen(fname, "r"))) { /* try in homedir */ --- 1740,1745 ---- *************** *** 1823,1835 **** { /* parse it, i.e., read name, try to alloc in cmap, add menu entry */ char cname[512]; int status; ! XColor color; while ((status = fscanf(colorfile,"%[^\n]\n", cname)) && (status != EOF)) { ! if (!XParseColor(dpy, cmap, cname, &color)) continue; ! if (!XAllocColor(dpy, cmap, &color)) { fprintf(stderr, "Warning: color %s could not be allocated!\n", cname); --- 1755,1767 ---- { /* parse it, i.e., read name, try to alloc in cmap, add menu entry */ char cname[512]; int status; ! XColor xcolor; while ((status = fscanf(colorfile,"%[^\n]\n", cname)) && (status != EOF)) { ! if (!XParseColor(dpy, cmap, cname, &xcolor)) continue; ! if (!XAllocColor(dpy, cmap, &xcolor)) { fprintf(stderr, "Warning: color %s could not be allocated!\n", cname); *************** *** 1837,1867 **** } else { ! colorToAdd(pixmap_widget, color.pixel, ! ((cname[0] == '#') ? ! xpmGetRgbName(rgb_table, max_ncolors, ! (int) color.red, ! (int) color.green, ! (int) color.blue) : cname)); ! PWUseColorInTable(pixmap_widget, color.pixel, NULL, NULL, ! NULL, NULL, NULL, ! ((cname[0] == '#') ? ! xpmGetRgbName(rgb_table, max_ncolors, ! (int) color.red, ! (int) color.green, ! (int) color.blue) : cname)); } } fclose(colorfile); } else ! { /* allocate white and black in colormap */ ! colorToAdd(pixmap_widget, black, "black"); PWUseColorInTable(pixmap_widget, black, NULL, NULL, NULL, NULL, NULL, "black"); - colorToAdd(pixmap_widget, white, "white"); - PWUseColorInTable(pixmap_widget, white, - NULL, NULL, NULL, NULL, NULL, "white"); } } --- 1769,1784 ---- } else { ! PWUseColorInTable(pixmap_widget, xcolor.pixel, NULL, NULL, ! NULL, NULL, NULL, cname); } } fclose(colorfile); } else ! { /* allocate black in colormap */ PWUseColorInTable(pixmap_widget, black, NULL, NULL, NULL, NULL, NULL, "black"); } } *************** *** 1987,2007 **** #endif /* DEBUG */ if (resources.privateColormap) { ! XColor color; /* create a private colormap */ cmap = XCreateColormap(dpy, DefaultRootWindow(dpy), DefaultVisual(dpy, screen), AllocNone); /* allocate black and white */ ! color.red = 0xffff; ! color.blue = 0xffff; ! color.green = 0xffff; ! XAllocColor(dpy, cmap, &color); ! white = color.pixel; ! color.red = 0; ! color.blue = 0; ! color.green = 0; ! XAllocColor(dpy, cmap, &color); ! black = color.pixel; n = 0; XtSetArg(wargs[n], XtNcolormap, cmap); n++; --- 1904,1924 ---- #endif /* DEBUG */ if (resources.privateColormap) { ! XColor xcolor; /* create a private colormap */ cmap = XCreateColormap(dpy, DefaultRootWindow(dpy), DefaultVisual(dpy, screen), AllocNone); /* allocate black and white */ ! xcolor.red = 0xffff; ! xcolor.blue = 0xffff; ! xcolor.green = 0xffff; ! XAllocColor(dpy, cmap, &xcolor); ! white = xcolor.pixel; ! xcolor.red = 0; ! xcolor.blue = 0; ! xcolor.green = 0; ! XAllocColor(dpy, cmap, &xcolor); ! black = xcolor.pixel; n = 0; XtSetArg(wargs[n], XtNcolormap, cmap); n++; *************** *** 2011,2020 **** white = WhitePixel(dpy,screen); black = BlackPixel(dpy,screen); } - colorInMenu = (char *) XtMalloc((ncolors + 1)*sizeof(char)); /* +1 for - transp. */ - bzero(colorInMenu, (ncolors + 1)*sizeof(char)); - max_ncolors = xpmReadRgbNames(rgb_fname, rgb_table); #ifdef USE_ATHENA check_mark = XCreateBitmapFromData(XtDisplay(top_widget), --- 1928,1933 ---- *************** *** 2022,2027 **** --- 1935,1946 ---- xlogo16_bits, xlogo16_width, xlogo16_height); + #else + #if XmVersion > 1001 /* Motif 1.2 or > */ + /* Disable Motif 1.2 drag and drop */ + XtVaSetValues(XmGetXmDisplay(dpy), XmNdragInitiatorProtocolStyle, + XmDRAG_NONE, NULL); + #endif #endif /* USE_ATHENA */ XtAppAddActions(pixmap_context, actions_table, XtNumber(actions_table)); #ifndef USE_ATHENA *** Pixmap.h.orig Fri Aug 30 09:16:37 1996 --- Pixmap.h Fri Aug 30 09:16:37 1996 *************** *** 1,5 **** /* ! * $Id: Pixmap.h,v 1.13 1996/08/19 12:39:13 lmallet Exp $ * * Copyright (c) 1991-1994 Lionel MALLET * --- 1,5 ---- /* ! * $Id: Pixmap.h,v 1.15 1996/08/30 09:41:20 lmallet Exp $ * * Copyright (c) 1991-1994 Lionel MALLET * *************** *** 195,201 **** #define ImmediateMoveRequest "ImmediateMoveRequest" #define NoColorName "None" - #define UNDEF_PIXEL 0x80 #define TRANSPARENT(dpy, scr_num) (1<dialog_widget = XmCreateFileSelectionDialog(top_widget, name, ! wargs, 1); ! XmStringFree(xmstr); popup->shell_widget = XtParent(popup->dialog_widget); XtUnmanageChild(XmFileSelectionBoxGetChild(popup->dialog_widget, *** Pixmap.c.orig Mon Sep 2 06:40:21 1996 --- Pixmap.c Mon Sep 2 06:32:18 1996 *************** *** 1,5 **** /* ! * $Id: Pixmap.c,v 1.19 1996/08/16 13:50:17 lmallet Exp $ * * Copyright (c) 1991-1994 Lionel MALLET * --- 1,5 ---- /* ! * $Id: Pixmap.c,v 1.22 1996/09/02 08:32:37 lmallet Exp $ * * Copyright (c) 1991-1994 Lionel MALLET * *************** *** 55,61 **** * Author: Davor Matic, MIT X Consortium */ ! static char rcsid[] = "$Id: Pixmap.c,v 1.19 1996/08/16 13:50:17 lmallet Exp $"; #include #include --- 55,61 ---- * Author: Davor Matic, MIT X Consortium */ ! static char rcsid[] = "$Id: Pixmap.c,v 1.22 1996/09/02 08:32:37 lmallet Exp $"; #include #include *************** *** 80,85 **** --- 80,100 ---- static unsigned int depth; static int screen; static Display *dpy; + static int max_ncolors = -1; + + /* picked up from rgb.c of Xpm lib */ + static char *rgb_fname = RGBF ; + #ifndef UNUSE_XPM + typedef struct { /* rgb values and ascii names (from rgb text file) */ + int r, g, b; /* rgb values, range of 0 -> 65535 */ + char *name; /* color mnemonic of rgb value */ + } RgbName; + #define MAX_RGBNAMES 1024 + #endif /* UNUSE_XPM */ + static RgbName rgb_table[MAX_RGBNAMES]; + + extern int xpmReadRgbNames(); + extern char *xpmGetRgbName(); #define DefaultGridTolerance 5 #define DefaultPixmapWidth 32 *************** *** 92,97 **** --- 107,115 ---- #define DefaultDistance 10 #define DefaultSquareSize 20 + /* max display depth to use an array for color table */ + #define MAX_DEPTH 8 + static XtResource resources[] = { #define offset(field) XtOffset(PixmapWidget, pixmap.field) {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), *************** *** 316,321 **** --- 334,411 ---- #if NeedFunctionPrototypes + static void ResetColorUse(PWColorInfo *root) + #else + static void ResetColorUse(root) + PWColorInfo *root; + #endif + { + if (root != NULL) { + root->in_xpm = -1; + ResetColorUse(root->left); + ResetColorUse(root->right); + } + } + + #if NeedFunctionPrototypes + static void ResetPWColorsUse(PixmapWidget PW) + #else + static void ResetPWColorsUse(PW) + PixmapWidget PW; + #endif + { + if (depth <= MAX_DEPTH) { + /* colorTable is an array, pixel is the entry index */ + int i; + + for (i = 0 ; i < (1<pixmap.colorTable[i]) + PW->pixmap.colorTable[i]->in_xpm = -1; + } else { + ResetColorUse(*(PW->pixmap.colorTable)); + } + } + + #if NeedFunctionPrototypes + static PWColorInfo *GetColorWithPixel(PWColorInfo *root, Pixel pixel) + #else + static PWColorInfo *GetColorWithPixel(root, pixel) + PWColorInfo *root; + Pixel pixel; + #endif + { + if (root != NULL) { + if (root->pixel == pixel) + return root; + else if (pixel < root->pixel) + return GetColorWithPixel(root->left, pixel); + else + return GetColorWithPixel(root->right, pixel); + } else + return root; + } + + #if NeedFunctionPrototypes + static PWColorInfo *AddColor(PWColorInfo *root, PWColorInfo *color) + #else + static PWColorInfo *AddColor(root, color) + PWColorInfo *root; + PWColorInfo *color; + #endif + { + if (root == NULL) { + return color; + } else { + if (color->pixel < root->pixel) + root->left = AddColor(root->left, color); + else + root->right = AddColor(root->right, color); + + return root; + } + } + + #if NeedFunctionPrototypes Boolean PWQueryGrid(Widget w) #else Boolean PWQueryGrid(w) *************** *** 776,782 **** attribs->npixels = 0; attribs->colorsymbols = (XpmColorSymbol *)0; attribs->numsymbols = 0; ! attribs->rgb_fname = NULL; attribs->nextensions = 0; attribs->extensions = (XpmExtension *)0; attribs->ncolors = 0; --- 866,872 ---- attribs->npixels = 0; attribs->colorsymbols = (XpmColorSymbol *)0; attribs->numsymbols = 0; ! attribs->rgb_fname = rgb_fname; attribs->nextensions = 0; attribs->extensions = (XpmExtension *)0; attribs->ncolors = 0; *************** *** 875,880 **** --- 965,971 ---- XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap, screenConvertArg, XtNumber(screenConvertArg)); + } #if NeedFunctionPrototypes *************** *** 886,892 **** #endif { int status, i, shift = 0; ! XImage *image, *mask_image, *buffer, *mask_buffer; XpmAttributes attribs; Pixel *pixel; XpmInfo infos; --- 977,983 ---- #endif { int status, i, shift = 0; ! XImage *image, *mask_image; XpmAttributes attribs; Pixel *pixel; XpmInfo infos; *************** *** 978,1021 **** color->g4_color, color->g_color, color->c_color); - - if (PW->pixmap.AddColorNotify != (AddColorNotifyProc) 0) - PW->pixmap.AddColorNotify((Widget) PW, - *(pixel-shift), - color->c_color); } } if (PW->pixmap.hints_cmt) XtFree(PW->pixmap.hints_cmt); if (infos.hints_cmt) PW->pixmap.hints_cmt = XtNewString(infos.hints_cmt); if (PW->pixmap.colors_cmt) XtFree(PW->pixmap.colors_cmt); if (infos.colors_cmt) PW->pixmap.colors_cmt = XtNewString(infos.colors_cmt); if (PW->pixmap.pixels_cmt) XtFree(PW->pixmap.pixels_cmt); if (infos.pixels_cmt) PW->pixmap.pixels_cmt = XtNewString(infos.pixels_cmt); if (!mask_image) /* Xpm returns NULL when transp. is not used */ mask_image = CreateMaskImage(PW, image->width, image->height); else SetTransparentPixels(PW, image, mask_image); - buffer = CreatePixmapImage(PW, PW->pixmap.image->width, - PW->pixmap.image->height); - mask_buffer = CreateMaskImage(PW, PW->pixmap.image->width, - PW->pixmap.image->height); - - TransferImageData(PW->pixmap.image, buffer); - TransferImageData(PW->pixmap.mask_image, mask_buffer); - - DestroyPixmapImage(&PW->pixmap.image); DestroyPixmapImage(&PW->pixmap.buffer); - DestroyMaskImage(&PW->pixmap.mask_image); DestroyMaskImage(&PW->pixmap.mask_buffer); ! PW->pixmap.image = image; PW->pixmap.mask_image = mask_image; - PW->pixmap.buffer = buffer; - PW->pixmap.mask_buffer = mask_buffer; PW->pixmap.width = xpm_image.width; PW->pixmap.height = xpm_image.height; --- 1069,1107 ---- color->g4_color, color->g_color, color->c_color); } } + if (PW->pixmap.hints_cmt) XtFree(PW->pixmap.hints_cmt); if (infos.hints_cmt) PW->pixmap.hints_cmt = XtNewString(infos.hints_cmt); + else + PW->pixmap.hints_cmt = NULL; + if (PW->pixmap.colors_cmt) XtFree(PW->pixmap.colors_cmt); if (infos.colors_cmt) PW->pixmap.colors_cmt = XtNewString(infos.colors_cmt); + else + PW->pixmap.colors_cmt = NULL; + if (PW->pixmap.pixels_cmt) XtFree(PW->pixmap.pixels_cmt); if (infos.pixels_cmt) PW->pixmap.pixels_cmt = XtNewString(infos.pixels_cmt); + else + PW->pixmap.pixels_cmt = NULL; if (!mask_image) /* Xpm returns NULL when transp. is not used */ mask_image = CreateMaskImage(PW, image->width, image->height); else SetTransparentPixels(PW, image, mask_image); DestroyPixmapImage(&PW->pixmap.buffer); DestroyMaskImage(&PW->pixmap.mask_buffer); ! ! PW->pixmap.buffer = PW->pixmap.image; ! PW->pixmap.mask_buffer = PW->pixmap.mask_image; ! PW->pixmap.image = image; PW->pixmap.mask_image = mask_image; PW->pixmap.width = xpm_image.width; PW->pixmap.height = xpm_image.height; *************** *** 1055,1063 **** screen = DefaultScreen(dpy); depth = DefaultDepth(dpy,screen); /* allocate max colors + 1 colorTable entries because 0 is transparent */ ! new->pixmap.colorTable = (PWColorInfo **) XtCalloc((1<pixmap.notify = NULL; new->pixmap.cardinal = 0; --- 1141,1157 ---- screen = DefaultScreen(dpy); depth = DefaultDepth(dpy,screen); + if (max_ncolors == -1) + max_ncolors = xpmReadRgbNames(rgb_fname, rgb_table); + /* allocate max colors + 1 colorTable entries because 0 is transparent */ ! if (depth <= MAX_DEPTH) { ! new->pixmap.colorTable = (PWColorInfo **) XtCalloc((1<pixmap.colorTable = XtNew(PWColorInfo *); ! *(new->pixmap.colorTable) = NULL; ! } new->pixmap.notify = NULL; new->pixmap.cardinal = 0; *************** *** 1072,1077 **** --- 1166,1172 ---- new->pixmap.colors_cmt = NULL; new->pixmap.pixels_cmt = NULL; new->pixmap.filename = XtNewString(new->pixmap.filename); + new->pixmap.status = NULL; new->pixmap.request_stack = (PWRequestStack *) XtMalloc(sizeof(PWRequestStack)); *************** *** 1164,1179 **** /* add transparent pixel in ColorTable */ PWUseColorInTable((Widget)new, TRANSPARENT(dpy, screen), NULL, NULL, NULL, NULL, NULL, NoColorName); - if (new->pixmap.AddColorNotify != (AddColorNotifyProc) 0) - new->pixmap.AddColorNotify((Widget)new, TRANSPARENT(dpy, screen), - NoColorName); /* add clear pixel in ColorTable */ PWUseColorInTable((Widget)new, new->pixmap.clear_pixel, NULL, NULL, NULL, NULL, NULL, "white"); - if (new->pixmap.AddColorNotify != (AddColorNotifyProc) 0) - new->pixmap.AddColorNotify((Widget)new, new->pixmap.clear_pixel, - "white"); /* Read file */ readFile(new, new->pixmap.filename); --- 1259,1268 ---- *************** *** 1313,1325 **** color->g4_color, color->g_color, color->c_color); - - if (PW->pixmap.AddColorNotify != (AddColorNotifyProc) 0) - PW->pixmap.AddColorNotify((Widget)PW, - *(pixel-shift), - color->c_color); } } if (!mask_image) /* Xpm returns NULL when transp. is not used */ mask_image = CreateMaskImage(PW, image->width, image->height); else SetTransparentPixels(PW, image, mask_image); --- 1402,1410 ---- color->g4_color, color->g_color, color->c_color); } } + if (!mask_image) /* Xpm returns NULL when transp. is not used */ mask_image = CreateMaskImage(PW, image->width, image->height); else SetTransparentPixels(PW, image, mask_image); *************** *** 1359,1368 **** #endif { PixmapWidget PW = (PixmapWidget) w; ! sprintf(PW->pixmap.status, ! "Filename: %s Size:%dx%d", ! PW->pixmap.filename, PW->pixmap.width, PW->pixmap.height); return PW->pixmap.status; } --- 1444,1470 ---- #endif { PixmapWidget PW = (PixmapWidget) w; + + char size_buf[80]; + char *status_ptr; + + sprintf(size_buf, "%dx%d", PW->pixmap.width, PW->pixmap.height); ! /* 16 is lenght of "Filename: " and " Size:" ! 1 is NULL ! don't realloc pixmap.status since alloc might ! fail and we don't want to */ ! if ((status_ptr = XtMalloc((strlen(size_buf) + ! strlen(PW->pixmap.filename) + ! 16 + 1) * sizeof(char)))) ! { ! if (PW->pixmap.status) ! XtFree(PW->pixmap.status); ! PW->pixmap.status = status_ptr; ! sprintf(PW->pixmap.status, ! "Filename: %s Size:%dx%d", ! PW->pixmap.filename, PW->pixmap.width, PW->pixmap.height); ! } return PW->pixmap.status; } *************** *** 1453,1458 **** --- 1555,1604 ---- } #if NeedFunctionPrototypes + PWColorInfo *PWGetColor(Widget w, Pixel pixel) + #else + PWColorInfo *PWGetColor(w, pixel) + Widget w; + Pixel pixel; + #endif + { + PixmapWidget PW = (PixmapWidget) w; + + if (depth <= MAX_DEPTH) { + /* colorTable is an array, pixel is the entry index */ + /* index in colorTable is 0 for transparent and pixel+1 for others */ + int index = (pixel == TRANSPARENT(dpy, screen) ? 0 : pixel + 1); + + return (PW->pixmap.colorTable[index]); + } else { + /* colorTable is a B-tree, find proper entry recursively */ + return GetColorWithPixel(*(PW->pixmap.colorTable), pixel); + } + } + + #if NeedFunctionPrototypes + void PWAddColor(Widget w, PWColorInfo *color) + #else + void PWAddColor(w, color) + Widget w; + PWColorInfo *color; + #endif + { + PixmapWidget PW = (PixmapWidget) w; + + if (depth <= MAX_DEPTH) { + /* colorTable is an array, pixel is the entry index */ + /* index in colorTable is 0 for transparent and pixel+1 for others */ + int index = (color->pixel == TRANSPARENT(dpy, screen) ? 0 : color->pixel + 1); + + PW->pixmap.colorTable[index] = color; + } else { + /* colorTable is a B-tree, find proper entry recursively */ + *(PW->pixmap.colorTable) = AddColor(*(PW->pixmap.colorTable), color); + } + } + + #if NeedFunctionPrototypes void PWUseColorInTable(Widget w, Pixel pixel, char *symbol, char *sname, char *mname, char *g4name, char *gname, char *cname) #else *************** *** 1464,1489 **** /* name are not used as is, instead memory is malloc'ed to fit in */ { PixmapWidget PW = (PixmapWidget) w; ! /* index in colorTable is 0 for transparent and pixel+1 for others */ ! int index = (pixel == TRANSPARENT(dpy, screen) ? 0 : pixel + 1); ! ! if (!PW->pixmap.colorTable[index]) /* not yet used color ! probably not in colorTable */ { ! PW->pixmap.colorTable[index]=(PWColorInfo*)XtCalloc(1, ! sizeof(PWColorInfo)); ! PW->pixmap.colorTable[index]->symbol = 0; ! PW->pixmap.colorTable[index]->s_name = 0; ! PW->pixmap.colorTable[index]->m_name = 0; ! PW->pixmap.colorTable[index]->g4_name = 0; ! PW->pixmap.colorTable[index]->g_name = 0; ! PW->pixmap.colorTable[index]->c_name = 0; ! PW->pixmap.colorTable[index]->pixel = pixel; } PWUpdateColorInTable(w, pixel, symbol, sname, mname, g4name, gname, cname); } --- 1610,1644 ---- /* name are not used as is, instead memory is malloc'ed to fit in */ { PixmapWidget PW = (PixmapWidget) w; ! Boolean is_new_color = False; ! PWColorInfo *new_color; ! ! if (PWGetColor(w, pixel) == NULL) /* not yet used color ! probably not in colorTable */ { ! is_new_color = True; ! ! new_color = XtNew(PWColorInfo); ! ! new_color->symbol = 0; ! new_color->s_name = 0; ! new_color->m_name = 0; ! new_color->g4_name = 0; ! new_color->g_name = 0; ! new_color->c_name = 0; ! new_color->pixel = pixel; ! new_color->left = NULL; ! new_color->right = NULL; ! ! PWAddColor(w, new_color); } PWUpdateColorInTable(w, pixel, symbol, sname, mname, g4name, gname, cname); + if (is_new_color && + (PW->pixmap.AddColorNotify != (AddColorNotifyProc) 0)) + PW->pixmap.AddColorNotify(w, pixel, new_color->c_name); } *************** *** 1499,1563 **** /* name are not used as is, instead memory is malloc'ed to fit in */ { PixmapWidget PW = (PixmapWidget) w; ! /* index in colorTable is 0 for transparent and pixel+1 for others */ ! int index = (pixel == TRANSPARENT(dpy, screen) ? 0 : pixel + 1); ! if (!PW->pixmap.colorTable[index]) return; /* inexistent color in Table */ /* Update the color info in ColorTable */ ! if ((symbol) && ((!PW->pixmap.colorTable[index]->symbol) || ! (strcmp(symbol, PW->pixmap.colorTable[index]->symbol)))) { ! if (PW->pixmap.colorTable[index]->symbol) ! XtFree(PW->pixmap.colorTable[index]->symbol); ! PW->pixmap.colorTable[index]->symbol = XtNewString(symbol); } ! if ((sname) && ((!PW->pixmap.colorTable[index]->s_name) || ! (strcmp(sname, PW->pixmap.colorTable[index]->s_name)))) { ! if (PW->pixmap.colorTable[index]->s_name) ! XtFree(PW->pixmap.colorTable[index]->s_name); ! PW->pixmap.colorTable[index]->s_name = XtNewString(sname); } ! if ((mname) && ((!PW->pixmap.colorTable[index]->m_name) || ! (strcmp(mname, PW->pixmap.colorTable[index]->m_name)))) { ! if (PW->pixmap.colorTable[index]->m_name) ! XtFree(PW->pixmap.colorTable[index]->m_name); ! PW->pixmap.colorTable[index]->m_name = XtNewString(mname); } ! if ((g4name) && ((!PW->pixmap.colorTable[index]->g4_name) || ! (strcmp(g4name, PW->pixmap.colorTable[index]->g4_name)))) { ! if (PW->pixmap.colorTable[index]->g4_name) ! XtFree(PW->pixmap.colorTable[index]->g4_name); ! PW->pixmap.colorTable[index]->g4_name = XtNewString(g4name); } ! if ((gname) && ((!PW->pixmap.colorTable[index]->g_name) || ! (strcmp(gname, PW->pixmap.colorTable[index]->g_name)))) { ! if (PW->pixmap.colorTable[index]->g_name) ! XtFree(PW->pixmap.colorTable[index]->g_name); ! PW->pixmap.colorTable[index]->g_name = XtNewString(gname); ! } ! if ((cname) && ((!PW->pixmap.colorTable[index]->c_name) || ! ((strcmp(cname, PW->pixmap.colorTable[index]->c_name)) && ! ((cname[0] != '#') || ! (PW->pixmap.colorTable[index]->c_name[0] == '#'))))) { ! if (PW->pixmap.colorTable[index]->c_name) ! XtFree(PW->pixmap.colorTable[index]->c_name); ! PW->pixmap.colorTable[index]->c_name = XtNewString(cname); } ! else if ((!cname) && (!PW->pixmap.colorTable[index]->c_name)) { ! XColor color; ! color.pixel = pixel; ! XQueryColor(dpy, PW->core.colormap, &color); ! PW->pixmap.colorTable[index]->c_name = (char *)XtMalloc(15*sizeof(char)); ! sprintf(PW->pixmap.colorTable[index]->c_name, "#%04X%04X%04X", ! color.red, color.green, color.blue); } } --- 1654,1738 ---- /* name are not used as is, instead memory is malloc'ed to fit in */ { PixmapWidget PW = (PixmapWidget) w; ! PWColorInfo *color = PWGetColor(w, pixel); ! if (color == NULL) return; /* inexistent color in Table */ /* Update the color info in ColorTable */ ! if ((symbol) && ((!color->symbol) || (strcmp(symbol, color->symbol)))) { ! if (color->symbol) ! XtFree(color->symbol); ! color->symbol = XtNewString(symbol); } ! if ((sname) && ((!color->s_name) || (strcmp(sname, color->s_name)))) { ! if (color->s_name) ! XtFree(color->s_name); ! color->s_name = XtNewString(sname); } ! if ((mname) && ((!color->m_name) || (strcmp(mname, color->m_name)))) { ! if (color->m_name) ! XtFree(color->m_name); ! color->m_name = XtNewString(mname); } ! if ((g4name) && ((!color->g4_name) || (strcmp(g4name, color->g4_name)))) { ! if (color->g4_name) ! XtFree(color->g4_name); ! color->g4_name = XtNewString(g4name); } ! if ((gname) && ((!color->g_name) || (strcmp(gname, color->g_name)))) { ! if (color->g_name) ! XtFree(color->g_name); ! color->g_name = XtNewString(gname); ! } ! if ((cname) && ((!color->c_name) || ! ((strcmp(cname, color->c_name)) && ! ((cname[0] != '#') || (color->c_name[0] == '#'))))) { ! if (color->c_name) ! XtFree(color->c_name); ! ! /* try to get a name from rgb_table */ ! if (cname[0] == '#') ! { ! XColor xcolor; ! char *rgb_name; ! ! xcolor.pixel = pixel; ! XQueryColor(dpy, PW->core.colormap, &xcolor); ! rgb_name = xpmGetRgbName(rgb_table, max_ncolors, ! (int) xcolor.red, ! (int) xcolor.green, ! (int) xcolor.blue); ! ! if (rgb_name) ! cname=rgb_name; ! } ! ! color->c_name = XtNewString(cname); } ! else if ((!cname) && (!color->c_name)) { ! XColor xcolor; ! char *rgb_name; ! xcolor.pixel = pixel; ! XQueryColor(dpy, PW->core.colormap, &xcolor); ! if (!(rgb_name = xpmGetRgbName(rgb_table, max_ncolors, ! (int) xcolor.red, ! (int) xcolor.green, ! (int) xcolor.blue))) ! { ! color->c_name = (char *)XtMalloc(15*sizeof(char)); ! sprintf(color->c_name, "#%04X%04X%04X", ! xcolor.red, xcolor.green, xcolor.blue); ! } else { ! color->c_name = XtNewString(rgb_name); ! } } } *************** *** 1660,1672 **** register Position x, y; register Pixel pxl; unsigned int *data, color_index = 0; - unsigned int *InUse = (unsigned int *)XtCalloc((1<pixmap.hints_cmt || PW->pixmap.colors_cmt || PW->pixmap.pixels_cmt) { --- 1835,1846 ---- register Position x, y; register Pixel pxl; unsigned int *data, color_index = 0; unsigned int i, j, k; XpmColor *color; XpmImage *xpm_image = (XpmImage *)XtMalloc(sizeof(XpmImage)); XpmInfo *infos = (XpmInfo *)XtMalloc(sizeof(XpmInfo)); ! ResetPWColorsUse(PW); if (PW->pixmap.hints_cmt || PW->pixmap.colors_cmt || PW->pixmap.pixels_cmt) { *************** *** 1702,1714 **** for (y = 0, data = xpm_image->data; y < image->height; y++) for (x = 0; x < image->width; x++, data++) { pxl = GetPxlFromImageAndMask(image, mask_image, x, y); ! if ((color_index = InUse[pxl]) == -1) { /* Add the color in colorTable */ - Pixel idx = (pxl == TRANSPARENT(dpy, screen) ? 0 : pxl + 1); - color_index = xpm_image->ncolors; ! InUse[pxl] = color_index; xpm_image->ncolors++; xpm_image->colorTable = --- 1876,1890 ---- for (y = 0, data = xpm_image->data; y < image->height; y++) for (x = 0; x < image->width; x++, data++) { + PWColorInfo *pw_color; + pxl = GetPxlFromImageAndMask(image, mask_image, x, y); ! pw_color = PWGetColor((Widget) PW, pxl); ! ! if ((color_index = pw_color->in_xpm) == -1) { /* Add the color in colorTable */ color_index = xpm_image->ncolors; ! pw_color->in_xpm = color_index; xpm_image->ncolors++; xpm_image->colorTable = *************** *** 1716,1726 **** xpm_image->ncolors * sizeof(XpmColor)); color = xpm_image->colorTable+color_index; ! color->symbolic = XtNewString(PW->pixmap.colorTable[idx]->s_name); ! color->m_color = XtNewString(PW->pixmap.colorTable[idx]->m_name); ! color->g4_color = XtNewString(PW->pixmap.colorTable[idx]->g4_name); ! color->g_color = XtNewString(PW->pixmap.colorTable[idx]->g_name); ! color->c_color = XtNewString(PW->pixmap.colorTable[idx]->c_name); } /* put color index in XpmImage */ --- 1892,1902 ---- xpm_image->ncolors * sizeof(XpmColor)); color = xpm_image->colorTable+color_index; ! color->symbolic = XtNewString(pw_color->s_name); ! color->m_color = XtNewString(pw_color->m_name); ! color->g4_color = XtNewString(pw_color->g4_name); ! color->g_color = XtNewString(pw_color->g_name); ! color->c_color = XtNewString(pw_color->c_name); } /* put color index in XpmImage */ *************** *** 1743,1750 **** *s = '\0'; } - XtFree((char *)InUse); - *xpm_image_return = xpm_image; *infos_return = infos; } --- 1919,1924 ----