+
+/*
+ * Allocate new pixel values and update color palette buttons.
+ * This is needed for screens without dynamicColor.
+ */
+static void allocNewColors(void)
+{
+ int i, n;
+ Arg args[10];
+ static unsigned long pixels[XmCO_MAX_NUM_COLORS*5];
+ static int count = 0;
+
+ if(count)
+ {
+ /* free the cells from last selection */
+ XFreeColors(style.display, style.colormap, pixels, count, 0);
+ count=0;
+ }
+
+ for (i=0; i<pCurrentPalette->num_of_colors; i++)
+ {
+ n=0;
+ if (XAllocColor(style.display, style.colormap,
+ &(pCurrentPalette->color[i].fg)) == 0) break;
+ pixels[count++] = pCurrentPalette->color[i].fg.pixel;
+
+ if (XAllocColor(style.display, style.colormap,
+ &(pCurrentPalette->color[i].bg)) == 0) break;
+ pixels[count++] = pCurrentPalette->color[i].bg.pixel;
+ XtSetArg (args[n], XmNbackground,
+ pCurrentPalette->color[i].bg.pixel); n++;
+
+ if (XAllocColor(style.display, style.colormap,
+ &(pCurrentPalette->color[i].sc)) == 0) break;
+ pixels[count++] = pCurrentPalette->color[i].sc.pixel;
+ XtSetArg (args[n], XmNarmColor,
+ pCurrentPalette->color[i].sc.pixel); n++;
+
+ if (UsePixmaps == FALSE)
+ {
+ if (XAllocColor(style.display, style.colormap,
+ &(pCurrentPalette->color[i].ts)) == 0) break;
+ pixels[count++] = pCurrentPalette->color[i].ts.pixel;
+ XtSetArg (args[n], XmNtopShadowColor,
+ pCurrentPalette->color[i].ts.pixel); n++;
+
+ if (XAllocColor(style.display, style.colormap,
+ &(pCurrentPalette->color[i].bs)) == 0) break;
+ pixels[count++] = pCurrentPalette->color[i].bs.pixel;
+ XtSetArg (args[n], XmNbottomShadowColor,
+ pCurrentPalette->color[i].bs.pixel); n++;
+ }
+ else /* create pixmaps for top/bottom shadow */
+ {
+ XmDestroyPixmap(style.screen, edit.pixmap25);
+ XmDestroyPixmap(style.screen, edit.pixmap75);
+
+ edit.pixmap25 = XmGetPixmap (style.screen,
+ "50_foreground",pCurrentPalette->color[i].bg.pixel,
+ WhitePixelOfScreen(style.screen));
+
+ edit.pixmap75 = XmGetPixmap (style.screen,
+ "50_foreground",pCurrentPalette->color[i].bg.pixel,
+ BlackPixelOfScreen(style.screen));
+
+ XtSetArg (args[n], XmNtopShadowPixmap, edit.pixmap25); n++;
+ XtSetArg (args[n], XmNbottomShadowPixmap, edit.pixmap75); n++;
+ }
+ XtSetValues(colorButton[i], args, n);
+ }
+}