rem: WMColorPanel	*panel; RImage		*image; WMPixmap	*pixmap; RColor		from; RColor		to; int			i; int			x,y;   globalFont = WMSystemFontOfSize(scrPtr, 12); panel = wmalloc(sizeof(WMColorPanel)); memset(panel, 0, sizeof(WMColorPanel));  panel->win = WMCreateWindowWithStyle(scrPtr, name, WMTitledWindowMask | WMClosableWindowMask | WMResizableWindowMask); WMResizeWidget(panel->win, PWIDTH, PHEIGHT); WMSetWindowTitle(panel->win, "Colors");    panel->mode = WMWheelModeColorPanel; panel->lastChanged = WMWheelModeColorPanel; panel->slidersmode = WMRGBModeColorPanel; panel->configurationPath = wstrappend(wusergnusteppath(), "/Library/Colors/");   panel->colorWell = WMCreateColorWell(panel->win); WMResizeWidget(panel->colorWell, 134, 36); WSetColorWellBordered(panel->colorWell, False); WMMoveWidget(panel->colorWell, 56, 4);  panel->magnifyBtn = WMCreateCommandButton(panel->win); WMResizeWidget(panel->magnifyBtn, 46, 36); WMMoveWidget(panel->magnifyBtn, 6,4); WMSetButtonImagePosition(panel->magnifyBtn, WIPImageOnly); WMSetButtonImage(panel->magnifyBtn, scrPtr->magnifyIcon); WMSetButtonAltImage(panel->magnifyBtn, scrPtr->magnifyAltIcon);  panel->wheelBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->wheelBtn, 46, 32); WMMoveWidget(panel->wheelBtn, 6, 44); WMSetButtonAction(panel->wheelBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->wheelBtn, WIPImageOnly); WMSetButtonImage(panel->wheelBtn, scrPtr->wheelIcon); WMSetButtonAltImage(panel->wheelBtn, scrPtr->wheelAltIcon);  panel->slidersBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->slidersBtn, 46, 32); WMMoveWidget(panel->slidersBtn, 52, 44); WMSetButtonAction(panel->slidersBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->slidersBtn, WIPImageOnly); WMSetButtonImage(panel->slidersBtn, scrPtr->rgbIcon); WMSetButtonAltImage(panel->slidersBtn, scrPtr->rgbAltIcon);  panel->customPaletteBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->customPaletteBtn, 46, 32); WMMoveWidget(panel->customPaletteBtn, 98, 44); WMSetButtonAction(panel->customPaletteBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->customPaletteBtn, WIPImageOnly); WMSetButtonImage(panel->customPaletteBtn, scrPtr->customPaletteIcon); WMSetButtonAltImage(panel->customPaletteBtn, scrPtr->customPaletteAltIcon);  panel->colorListBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->colorListBtn, 46, 32); WMMoveWidget(panel->colorListBtn, 144, 44); WMSetButtonAction(panel->colorListBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->colorListBtn, WIPImageOnly); WMSetButtonImage(panel->colorListBtn, scrPtr->colorListIcon); WMSetButtonAltImage(panel->colorListBtn, scrPtr->colorListAltIcon);   WMGroupButtons(panel->wheelBtn, panel->slidersBtn); WMGroupButtons(panel->wheelBtn, panel->customPaletteBtn); WMGroupButtons(panel->wheelBtn, panel->colorListBtn);   panel->wheelFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->wheelFrm, WRFlat); WMResizeWidget(panel->wheelFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->wheelFrm, 5, 80);  panel->wheelView = W_CreateView(W_VIEW(panel->wheelFrm));  W_ResizeView(panel->wheelView, colorWheelSize+4, colorWheelSize+4); W_MoveView(panel->wheelView, 0, 0);   WMCreateEventHandler(panel->wheelView, ButtonPressMask|ButtonReleaseMask|EnterWindowMask |LeaveWindowMask|ButtonMotionMask, wheelHandleActionEvents, panel);  WMCreateEventHandler(panel->wheelView, ExposureMask, wheelHandleEvents, panel);  panel->wheelBrightnessS = WMCreateSlider(panel->wheelFrm); WMResizeWidget(panel->wheelBrightnessS, 16, 153); WMMoveWidget(panel->wheelBrightnessS, 5+colorWheelSize+14, 1); WMSetSliderMinValue(panel->wheelBrightnessS, 0); WMSetSliderMaxValue(panel->wheelBrightnessS, 255); WMSetSliderAction(panel->wheelBrightnessS, wheelBrightnessSliderCallback, panel); WMSetSliderKnobThickness(panel->wheelBrightnessS, knobThickness);    panel->slidersFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->slidersFrm, WRFlat); WMResizeWidget(panel->slidersFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->slidersFrm, 4, 80);  panel->seperatorFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->seperatorFrm, WRPushed); WMResizeWidget(panel->seperatorFrm, PWIDTH - 8, 2); WMMoveWidget(panel->seperatorFrm, 0, 1);  panel->grayBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->grayBtn, 46, 24); WMMoveWidget(panel->grayBtn, 1, 8); WMSetButtonAction(panel->grayBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->grayBtn, WIPImageOnly); WMSetButtonImage(panel->grayBtn, scrPtr->grayIcon); WMSetButtonAltImage(panel->grayBtn, scrPtr->grayAltIcon);  panel->rgbBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->rgbBtn, 46, 24); WMMoveWidget(panel->rgbBtn, 47, 8); WMSetButtonAction(panel->rgbBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->rgbBtn, WIPImageOnly); WMSetButtonImage(panel->rgbBtn, scrPtr->rgbIcon); WMSetButtonAltImage(panel->rgbBtn, scrPtr->rgbAltIcon);  panel->cmykBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->cmykBtn, 46, 24); WMMoveWidget(panel->cmykBtn, 93, 8); WMSetButtonAction(panel->cmykBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->cmykBtn, WIPImageOnly); WMSetButtonImage(panel->cmykBtn, scrPtr->cmykIcon); WMSetButtonAltImage(panel->cmykBtn, scrPtr->cmykAltIcon);  panel->hsbBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->hsbBtn, 46, 24); WMMoveWidget(panel->hsbBtn, 139, 8); WMSetButtonAction(panel->hsbBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->hsbBtn, WIPImageOnly); WMSetButtonImage(panel->hsbBtn, scrPtr->hsbIcon); WMSetButtonAltImage(panel->hsbBtn, scrPtr->hsbAltIcon);   WMGroupButtons(panel->grayBtn, panel->rgbBtn); WMGroupButtons(panel->grayBtn, panel->cmykBtn); WMGroupButtons(panel->grayBtn, panel->hsbBtn);   panel->grayFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->grayFrm, WRFlat); WMResizeWidget(panel->grayFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->grayFrm, 0, 34);  panel->grayMinL = WMCreateLabel(panel->grayFrm); WMResizeWidget(panel->grayMinL, 20, 10); WMMoveWidget(panel->grayMinL, 2, 2); WMSetLabelText(panel->grayMinL, "0"); WMSetLabelTextAlignment(panel->grayMinL, WALeft); WMSetLabelTextColor(panel->grayMinL, WMDarkGrayColor(scrPtr)); WMSetLabelFont(panel->grayMinL, WMSystemFontOfSize(scrPtr, 8));  panel->grayMaxL = WMCreateLabel(panel->grayFrm); WMResizeWidget(panel->grayMaxL, 40, 10); WMMoveWidget(panel->grayMaxL, 104, 2); WMSetLabelText(panel->grayMaxL, "100"); WMSetLabelTextAlignment(panel->grayMaxL, WARight); WMSetLabelTextColor(panel->grayMaxL, WMDarkGrayColor(scrPtr)); WMSetLabelFont(panel->grayMaxL, WMSystemFontOfSize(scrPtr, 8));  panel->grayBrightnessS = WMCreateSlider(panel->grayFrm); WMResizeWidget(panel->grayBrightnessS, 141, 16); WMMoveWidget(panel->grayBrightnessS, 2, 14); WMSetSliderMinValue(panel->grayBrightnessS, 0); WMSetSliderMaxValue(panel->grayBrightnessS, 100); WMSetSliderKnobThickness(panel->grayBrightnessS, knobThickness); WMSetSliderAction(panel->grayBrightnessS, grayBrightnessSliderCallback, panel);  from.red = 0; from.green = 0; from.blue = 0;  to.red = 255; to.green = 255; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RDestroyImage(image); W_PaintText(W_VIEW(panel->grayBrightnessS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Brightness", strlen("Brightness")); WMSetSliderImage(panel->grayBrightnessS, pixmap); WMReleasePixmap(pixmap);  panel->grayBrightnessT = WMCreateTextField(panel->grayFrm); WMResizeWidget(panel->grayBrightnessT, 40, 18); WMMoveWidget(panel->grayBrightnessT, 146, 13); WMSetTextFieldAlignment(panel->grayBrightnessT, WALeft); WMAddNotificationObserver(grayBrightnessTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->grayBrightnessT);  image = RCreateImage(13,13,False); for (i=0; i < 7; i++) { for (x=0; x < 13; x++) { for (y=0; y < 13; y++) { image->data[0][y*13+x] = 255/6*i; image->data[1][y*13+x] = 255/6*i; image->data[2][y*13+x] = 255/6*i; } } panel->grayPresetBtn[i] = WMCreateCommandButton(panel->grayFrm); WMResizeWidget(panel->grayPresetBtn[i], 20, 24); WMMoveWidget(panel->grayPresetBtn[i], 2+(i*20), 34); WMSetButtonAction(panel->grayPresetBtn[i], grayPresetButtonCallback, panel); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); WMSetButtonImage(panel->grayPresetBtn[i], pixmap); WMSetButtonImagePosition(panel->grayPresetBtn[i], WIPImageOnly); WMReleasePixmap(pixmap); } RDestroyImage(image);    panel->rgbFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->rgbFrm, WRFlat); WMResizeWidget(panel->rgbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->rgbFrm, 0, 34);  panel->rgbMinL = WMCreateLabel(panel->rgbFrm); WMResizeWidget(panel->rgbMinL, 20, 10); WMMoveWidget(panel->rgbMinL, 2, 2); WMSetLabelText(panel->rgbMinL, "0"); WMSetLabelTextAlignment(panel->rgbMinL, WALeft); WMSetLabelTextColor(panel->rgbMinL, WMDarkGrayColor(scrPtr)); WMSetLabelFont(panel->rgbMinL, WMSystemFontOfSize(scrPtr, 8));  panel->rgbMaxL = WMCreateLabel(panel->rgbFrm); WMResizeWidget(panel->rgbMaxL, 40, 10); WMMoveWidget(panel->rgbMaxL, 104, 2); WMSetLabelText(panel->rgbMaxL, "255"); WMSetLabelTextAlignment(panel->rgbMaxL, WARight); WMSetLabelTextColor(panel->rgbMaxL, WMDarkGrayColor(scrPtr)); WMSetLabelFont(panel->rgbMaxL, WMSystemFontOfSize(scrPtr, 8));  panel->rgbRedS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbRedS, 141, 16); WMMoveWidget(panel->rgbRedS, 2, 14); WMSetSliderMinValue(panel->rgbRedS, 0); WMSetSliderMaxValue(panel->rgbRedS, 255); WMSetSliderKnobThickness(panel->rgbRedS, knobThickness); WMSetSliderAction(panel->rgbRedS, rgbSliderCallback, panel);  to.red = 255; to.green = 0; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->rgbRedS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Red", strlen("Red")); RDestroyImage(image); WMSetSliderImage(panel->rgbRedS, pixmap); WMReleasePixmap(pixmap);  panel->rgbRedT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbRedT, 40, 18); WMMoveWidget(panel->rgbRedT, 146, 13); WMSetTextFieldAlignment(panel->rgbRedT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->rgbRedT);   panel->rgbGreenS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbGreenS, 141, 16); WMMoveWidget(panel->rgbGreenS, 2, 36); WMSetSliderMinValue(panel->rgbGreenS, 0); WMSetSliderMaxValue(panel->rgbGreenS, 255); WMSetSliderKnobThickness(panel->rgbGreenS, knobThickness); WMSetSliderAction(panel->rgbGreenS, rgbSliderCallback, panel);  to.red = 0; to.green = 255; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->rgbGreenS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Green", strlen("Green")); RDestroyImage(image); WMSetSliderImage(panel->rgbGreenS, pixmap); WMReleasePixmap(pixmap);  panel->rgbGreenT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbGreenT, 40, 18); WMMoveWidget(panel->rgbGreenT, 146, 35); WMSetTextFieldAlignment(panel->rgbGreenT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->rgbGreenT);   panel->rgbBlueS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbBlueS, 141, 16); WMMoveWidget(panel->rgbBlueS, 2, 58); WMSetSliderMinValue(panel->rgbBlueS, 0); WMSetSliderMaxValue(panel->rgbBlueS, 255); WMSetSliderKnobThickness(panel->rgbBlueS, knobThickness); WMSetSliderAction(panel->rgbBlueS, rgbSliderCallback, panel);  to.red = 0; to.green = 0; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->rgbBlueS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Blue", strlen("Blue")); RDestroyImage(image); WMSetSliderImage(panel->rgbBlueS, pixmap); WMReleasePixmap(pixmap);  panel->rgbBlueT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbBlueT, 40, 18); WMMoveWidget(panel->rgbBlueT, 146, 57); WMSetTextFieldAlignment(panel->rgbBlueT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->rgbBlueT);    panel->cmykFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->cmykFrm, WRFlat); WMResizeWidget(panel->cmykFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->cmykFrm, 0, 34);  panel->cmykMinL = WMCreateLabel(panel->cmykFrm); WMResizeWidget(panel->cmykMinL, 20, 10); WMMoveWidget(panel->cmykMinL, 2, 2); WMSetLabelText(panel->cmykMinL, "0"); WMSetLabelTextAlignment(panel->cmykMinL, WALeft); WMSetLabelTextColor(panel->cmykMinL, WMDarkGrayColor(scrPtr)); WMSetLabelFont(panel->cmykMinL, WMSystemFontOfSize(scrPtr, 8));  panel->cmykMaxL = WMCreateLabel(panel->cmykFrm); WMResizeWidget(panel->cmykMaxL, 40, 10); WMMoveWidget(panel->cmykMaxL, 104, 2); WMSetLabelText(panel->cmykMaxL, "100"); WMSetLabelTextAlignment(panel->cmykMaxL, WARight); WMSetLabelTextColor(panel->cmykMaxL, WMDarkGrayColor(scrPtr)); WMSetLabelFont(panel->cmykMaxL, WMSystemFontOfSize(scrPtr, 8));  panel->cmykCyanS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykCyanS, 141, 16); WMMoveWidget(panel->cmykCyanS, 2, 14); WMSetSliderMinValue(panel->cmykCyanS, 0); WMSetSliderMaxValue(panel->cmykCyanS, 100); WMSetSliderKnobThickness(panel->cmykCyanS, knobThickness); WMSetSliderAction(panel->cmykCyanS, cmykSliderCallback, panel);  from.red = 255; from.green = 255; from.blue = 255;  to.red = 0; to.green = 255; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykCyanS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Cyan", strlen("Cyan")); RDestroyImage(image); WMSetSliderImage(panel->cmykCyanS, pixmap); WMReleasePixmap(pixmap);  panel->cmykCyanT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykCyanT, 40, 18); WMMoveWidget(panel->cmykCyanT, 146, 13); WMSetTextFieldAlignment(panel->cmykCyanT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykCyanT);   panel->cmykMagentaS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykMagentaS, 141, 16); WMMoveWidget(panel->cmykMagentaS, 2, 36); WMSetSliderMinValue(panel->cmykMagentaS, 0); WMSetSliderMaxValue(panel->cmykMagentaS, 100); WMSetSliderKnobThickness(panel->cmykMagentaS, knobThickness); WMSetSliderAction(panel->cmykMagentaS, cmykSliderCallback, panel);  to.red = 255; to.green = 0; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykMagentaS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Magenta", strlen("Magenta")); RDestroyImage(image); WMSetSliderImage(panel->cmykMagentaS, pixmap); WMReleasePixmap(pixmap);  panel->cmykMagentaT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykMagentaT, 40, 18); WMMoveWidget(panel->cmykMagentaT, 146, 35); WMSetTextFieldAlignment(panel->cmykMagentaT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykMagentaT);   panel->cmykYellowS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykYellowS, 141, 16); WMMoveWidget(panel->cmykYellowS, 2, 58); WMSetSliderMinValue(panel->cmykYellowS, 0); WMSetSliderMaxValue(panel->cmykYellowS, 100); WMSetSliderKnobThickness(panel->cmykYellowS, knobThickness); WMSetSliderAction(panel->cmykYellowS, cmykSliderCallback, panel);  to.red = 255; to.green = 255; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykYellowS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Yellow", strlen("Yellow")); RDestroyImage(image); WMSetSliderImage(panel->cmykYellowS, pixmap); WMReleasePixmap(pixmap);  panel->cmykYellowT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykYellowT, 40, 18); WMMoveWidget(panel->cmykYellowT, 146, 57); WMSetTextFieldAlignment(panel->cmykYellowT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykYellowT);   panel->cmykBlackS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykBlackS, 141, 16); WMMoveWidget(panel->cmykBlackS, 2, 80); WMSetSliderMinValue(panel->cmykBlackS, 0); WMSetSliderMaxValue(panel->cmykBlackS, 100); WMSetSliderValue(panel->cmykBlackS, 0); WMSetSliderKnobThickness(panel->cmykBlackS, knobThickness); WMSetSliderAction(panel->cmykBlackS, cmykSliderCallback, panel);  to.red = 0; to.green = 0; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykBlackS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Black", strlen("Black")); RDestroyImage(image); WMSetSliderImage(panel->cmykBlackS, pixmap); WMReleasePixmap(pixmap);  panel->cmykBlackT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykBlackT, 40, 18); WMMoveWidget(panel->cmykBlackT, 146, 79); WMSetTextFieldAlignment(panel->cmykBlackT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykBlackT);    panel->hsbFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->hsbFrm, WRFlat); WMResizeWidget(panel->hsbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->hsbFrm, 0, 34);  panel->hsbHueS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbHueS, 141, 16); WMMoveWidget(panel->hsbHueS, 2, 14); WMSetSliderMinValue(panel->hsbHueS, 0); WMSetSliderMaxValue(panel->hsbHueS, 359); WMSetSliderKnobThickness(panel->hsbHueS, knobThickness); WMSetSliderAction(panel->hsbHueS, hsbSliderCallback, panel);  panel->hsbHueT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbHueT, 40, 18); WMMoveWidget(panel->hsbHueT, 146, 13); WMSetTextFieldAlignment(panel->hsbHueT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->hsbHueT);   panel->hsbSaturationS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbSaturationS, 141, 16); WMMoveWidget(panel->hsbSaturationS, 2, 36); WMSetSliderMinValue(panel->hsbSaturationS, 0); WMSetSliderMaxValue(panel->hsbSaturationS, 100); WMSetSliderKnobThickness(panel->hsbSaturationS, knobThickness); WMSetSliderAction(panel->hsbSaturationS, hsbSliderCallback, panel);  panel->hsbSaturationT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbSaturationT, 40, 18); WMMoveWidget(panel->hsbSaturationT, 146, 35); WMSetTextFieldAlignment(panel->hsbSaturationT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->hsbSaturationT);   panel->hsbBrightnessS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbBrightnessS, 141, 16); WMMoveWidget(panel->hsbBrightnessS, 2, 58); WMSetSliderMinValue(panel->hsbBrightnessS, 0); WMSetSliderMaxValue(panel->hsbBrightnessS, 100); WMSetSliderKnobThickness(panel->hsbBrightnessS, knobThickness); WMSetSliderAction(panel->hsbBrightnessS, hsbSliderCallback, panel);  panel->hsbBrightnessT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbBrightnessT, 40, 18); WMMoveWidget(panel->hsbBrightnessT, 146, 57); WMSetTextFieldAlignment(panel->hsbBrightnessT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->hsbBrightnessT);    panel->customPaletteFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->customPaletteFrm, WRFlat); WMResizeWidget(panel->customPaletteFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->customPaletteFrm, 5, 80);  panel->customPaletteHistoryBtn = WMCreatePopUpButton(panel->customPaletteFrm); WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, "Spectrum"); WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, WMGetPopUpButtonNumberOfItems(panel->customPaletteHistoryBtn)-1); WMSetPopUpButtonAction(panel->customPaletteHistoryBtn, customPaletteHistoryCallback, panel); WMResizeWidget(panel->customPaletteHistoryBtn, PWIDTH - 8, 20); WMMoveWidget(panel->customPaletteHistoryBtn, 0, 0);  panel->customPaletteContentFrm = WMCreateFrame(panel->customPaletteFrm); WMSetFrameRelief(panel->customPaletteContentFrm, WRSunken); WMResizeWidget(panel->customPaletteContentFrm, PWIDTH - 8, PHEIGHT - 156); WMMoveWidget(panel->customPaletteContentFrm, 0, 23);  panel->customPaletteContentView = W_CreateView(W_VIEW(panel->customPaletteContentFrm));  W_ResizeView(panel->customPaletteContentView, customPaletteWidth, customPaletteHeight); W_MoveView(panel->customPaletteContentView, 2, 2);   WMCreateEventHandler(panel->customPaletteContentView, ButtonPressMask|ButtonReleaseMask|EnterWindowMask |LeaveWindowMask|ButtonMotionMask, customPaletteHandleActionEvents, panel);  WMCreateEventHandler(panel->customPaletteContentView, ExposureMask, customPaletteHandleEvents, panel);  panel->customPaletteMenuBtn = WMCreatePopUpButton(panel->customPaletteFrm); WMSetPopUpButtonPullsDown(panel->customPaletteMenuBtn, 1); WMSetPopUpButtonText(panel->customPaletteMenuBtn, "Palette"); WMSetPopUpButtonAction(panel->customPaletteMenuBtn, customPaletteMenuCallback, panel); WMResizeWidget(panel->customPaletteMenuBtn, PWIDTH - 8, 20); WMMoveWidget(panel->customPaletteMenuBtn, 0, PHEIGHT - 130);  WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "New from File...");		 WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Rename...");				 WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Remove");					 WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Copy");						 WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "New from Clipboard");	  WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 1, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 2, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 3, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 4, 0);  customRenderSpectrum(panel); panel->currentPalette = 0;    panel->colorListFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->colorListFrm, WRFlat); WMResizeWidget(panel->colorListFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->colorListFrm, 5, 80);  panel->colorListHistoryBtn = WMCreatePopUpButton(panel->colorListFrm); WMAddPopUpButtonItem(panel->colorListHistoryBtn, "X11-Colors"); WMSetPopUpButtonSelectedItem(panel->colorListHistoryBtn, WMGetPopUpButtonNumberOfItems(panel->colorListHistoryBtn)-1);  WMResizeWidget(panel->colorListHistoryBtn, PWIDTH - 8, 20); WMMoveWidget(panel->colorListHistoryBtn, 0, 0);  panel->colorListContentLst = WMCreateList(panel->colorListFrm); WMSetListAction(panel->colorListContentLst, colorListSelect, panel); WMSetListUserDrawProc(panel->colorListContentLst, colorListPaintItem); WMResizeWidget(panel->colorListContentLst, PWIDTH - 8, PHEIGHT - 156); WMMoveWidget(panel->colorListContentLst, 0, 23);  panel->colorListColorMenuBtn = WMCreatePopUpButton(panel->colorListFrm); WMSetPopUpButtonPullsDown(panel->colorListColorMenuBtn, 1); WMSetPopUpButtonText(panel->colorListColorMenuBtn, "Color");  WMResizeWidget(panel->colorListColorMenuBtn, (PWIDTH - 16)/2, 20); WMMoveWidget(panel->colorListColorMenuBtn, 0, PHEIGHT - 130);  panel->colorListListMenuBtn = WMCreatePopUpButton(panel->colorListFrm); WMSetPopUpButtonPullsDown(panel->colorListListMenuBtn, 1); WMSetPopUpButtonText(panel->colorListListMenuBtn, "List");  WMResizeWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2, 20); WMMoveWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2 + 8, PHEIGHT - 130);   WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win);  WMMapSubwidgets(panel->wheelFrm); WMMapSubwidgets(panel->slidersFrm); WMMapSubwidgets(panel->grayFrm); WMMapSubwidgets(panel->rgbFrm); WMMapSubwidgets(panel->cmykFrm); WMMapSubwidgets(panel->hsbFrm); WMMapSubwidgets(panel->customPaletteFrm); WMMapSubwidgets(panel->customPaletteContentFrm); WMMapSubwidgets(panel->colorListFrm);  readConfiguration(panel); readXColors(panel);  return panel;
add: WMColorPanel    *panel; RImage        *image; WMPixmap    *pixmap; RColor        from; RColor        to; WMColor        *textcolor; int            i; int            x,y;   panel = wmalloc(sizeof(WMColorPanel)); memset(panel, 0, sizeof(WMColorPanel));  panel->font8 = WMSystemFontOfSize(scrPtr, 8); panel->font12 = WMSystemFontOfSize(scrPtr, 12);  panel->win = WMCreateWindowWithStyle(scrPtr, name, WMTitledWindowMask | WMClosableWindowMask | WMResizableWindowMask); WMResizeWidget(panel->win, PWIDTH, PHEIGHT); WMSetWindowTitle(panel->win, "Colors");    panel->mode = WMWheelModeColorPanel; panel->lastChanged = WMWheelModeColorPanel; panel->slidersmode = WMRGBModeColorPanel; panel->configurationPath = wstrappend(wusergnusteppath(), "/Library/Colors/");   panel->colorWell = WMCreateColorWell(panel->win); WMResizeWidget(panel->colorWell, 134, 36); WSetColorWellBordered(panel->colorWell, False); WMMoveWidget(panel->colorWell, 56, 4);  panel->magnifyBtn = WMCreateCommandButton(panel->win); WMResizeWidget(panel->magnifyBtn, 46, 36); WMMoveWidget(panel->magnifyBtn, 6,4); WMSetButtonAction(panel->magnifyBtn, magnifyPutCursor, panel); WMSetButtonImagePosition(panel->magnifyBtn, WIPImageOnly); WMSetButtonImage(panel->magnifyBtn, scrPtr->magnifyIcon); WMSetButtonAltImage(panel->magnifyBtn, scrPtr->altMagnifyIcon);  panel->wheelBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->wheelBtn, 46, 32); WMMoveWidget(panel->wheelBtn, 6, 44); WMSetButtonAction(panel->wheelBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->wheelBtn, WIPImageOnly); WMSetButtonImage(panel->wheelBtn, scrPtr->wheelIcon);  panel->slidersBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->slidersBtn, 46, 32); WMMoveWidget(panel->slidersBtn, 52, 44); WMSetButtonAction(panel->slidersBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->slidersBtn, WIPImageOnly); WMSetButtonImage(panel->slidersBtn, scrPtr->rgbIcon);  panel->customPaletteBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->customPaletteBtn, 46, 32); WMMoveWidget(panel->customPaletteBtn, 98, 44); WMSetButtonAction(panel->customPaletteBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->customPaletteBtn, WIPImageOnly); WMSetButtonImage(panel->customPaletteBtn, scrPtr->customPaletteIcon);  panel->colorListBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->colorListBtn, 46, 32); WMMoveWidget(panel->colorListBtn, 144, 44); WMSetButtonAction(panel->colorListBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->colorListBtn, WIPImageOnly); WMSetButtonImage(panel->colorListBtn, scrPtr->colorListIcon);   WMGroupButtons(panel->wheelBtn, panel->slidersBtn); WMGroupButtons(panel->wheelBtn, panel->customPaletteBtn); WMGroupButtons(panel->wheelBtn, panel->colorListBtn);   panel->wheelFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->wheelFrm, WRFlat); WMResizeWidget(panel->wheelFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->wheelFrm, 5, 80);  panel->wheelView = W_CreateView(W_VIEW(panel->wheelFrm));  W_ResizeView(panel->wheelView, colorWheelSize+4, colorWheelSize+4); W_MoveView(panel->wheelView, 0, 0);   WMCreateEventHandler(panel->wheelView, ButtonPressMask|ButtonReleaseMask|EnterWindowMask |LeaveWindowMask|ButtonMotionMask, wheelHandleActionEvents, panel);  WMCreateEventHandler(panel->wheelView, ExposureMask, wheelHandleEvents, panel);  panel->wheelBrightnessS = WMCreateSlider(panel->wheelFrm); WMResizeWidget(panel->wheelBrightnessS, 16, 153); WMMoveWidget(panel->wheelBrightnessS, 5+colorWheelSize+14, 1); WMSetSliderMinValue(panel->wheelBrightnessS, 0); WMSetSliderMaxValue(panel->wheelBrightnessS, 255); WMSetSliderAction(panel->wheelBrightnessS, wheelBrightnessSliderCallback, panel); WMSetSliderKnobThickness(panel->wheelBrightnessS, knobThickness);    panel->slidersFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->slidersFrm, WRFlat); WMResizeWidget(panel->slidersFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->slidersFrm, 4, 80);  panel->seperatorFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->seperatorFrm, WRPushed); WMResizeWidget(panel->seperatorFrm, PWIDTH - 8, 2); WMMoveWidget(panel->seperatorFrm, 0, 1);  panel->grayBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->grayBtn, 46, 24); WMMoveWidget(panel->grayBtn, 1, 8); WMSetButtonAction(panel->grayBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->grayBtn, WIPImageOnly); WMSetButtonImage(panel->grayBtn, scrPtr->grayIcon);  panel->rgbBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->rgbBtn, 46, 24); WMMoveWidget(panel->rgbBtn, 47, 8); WMSetButtonAction(panel->rgbBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->rgbBtn, WIPImageOnly); WMSetButtonImage(panel->rgbBtn, scrPtr->rgbIcon);  panel->cmykBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->cmykBtn, 46, 24); WMMoveWidget(panel->cmykBtn, 93, 8); WMSetButtonAction(panel->cmykBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->cmykBtn, WIPImageOnly); WMSetButtonImage(panel->cmykBtn, scrPtr->cmykIcon);  panel->hsbBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask); WMResizeWidget(panel->hsbBtn, 46, 24); WMMoveWidget(panel->hsbBtn, 139, 8); WMSetButtonAction(panel->hsbBtn, modeButtonCallback, panel); WMSetButtonImagePosition(panel->hsbBtn, WIPImageOnly); WMSetButtonImage(panel->hsbBtn, scrPtr->hsbIcon);   WMGroupButtons(panel->grayBtn, panel->rgbBtn); WMGroupButtons(panel->grayBtn, panel->cmykBtn); WMGroupButtons(panel->grayBtn, panel->hsbBtn);  textcolor = WMDarkGrayColor(scrPtr);   panel->grayFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->grayFrm, WRFlat); WMResizeWidget(panel->grayFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->grayFrm, 0, 34);  panel->grayMinL = WMCreateLabel(panel->grayFrm); WMResizeWidget(panel->grayMinL, 20, 10); WMMoveWidget(panel->grayMinL, 2, 2); WMSetLabelText(panel->grayMinL, "0"); WMSetLabelTextAlignment(panel->grayMinL, WALeft); WMSetLabelTextColor(panel->grayMinL, textcolor); WMSetLabelFont(panel->grayMinL, panel->font8);  panel->grayMaxL = WMCreateLabel(panel->grayFrm); WMResizeWidget(panel->grayMaxL, 40, 10); WMMoveWidget(panel->grayMaxL, 104, 2); WMSetLabelText(panel->grayMaxL, "100"); WMSetLabelTextAlignment(panel->grayMaxL, WARight); WMSetLabelTextColor(panel->grayMaxL, textcolor); WMSetLabelFont(panel->grayMaxL, panel->font8);  panel->grayBrightnessS = WMCreateSlider(panel->grayFrm); WMResizeWidget(panel->grayBrightnessS, 141, 16); WMMoveWidget(panel->grayBrightnessS, 2, 14); WMSetSliderMinValue(panel->grayBrightnessS, 0); WMSetSliderMaxValue(panel->grayBrightnessS, 100); WMSetSliderKnobThickness(panel->grayBrightnessS, knobThickness); WMSetSliderAction(panel->grayBrightnessS, grayBrightnessSliderCallback, panel);  from.red = 0; from.green = 0; from.blue = 0;  to.red = 255; to.green = 255; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); RDestroyImage(image); W_PaintText(W_VIEW(panel->grayBrightnessS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Brightness", strlen("Brightness")); WMSetSliderImage(panel->grayBrightnessS, pixmap); WMReleasePixmap(pixmap);  panel->grayBrightnessT = WMCreateTextField(panel->grayFrm); WMResizeWidget(panel->grayBrightnessT, 40, 18); WMMoveWidget(panel->grayBrightnessT, 146, 13); WMSetTextFieldAlignment(panel->grayBrightnessT, WALeft); WMAddNotificationObserver(grayBrightnessTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->grayBrightnessT);  image = RCreateImage(13,13,False); for (i=0; i < 7; i++) { for (x=0; x < 13; x++) { for (y=0; y < 13; y++) { image->data[0][y*13+x] = 255/6*i; image->data[1][y*13+x] = 255/6*i; image->data[2][y*13+x] = 255/6*i; } } panel->grayPresetBtn[i] = WMCreateCommandButton(panel->grayFrm); WMResizeWidget(panel->grayPresetBtn[i], 20, 24); WMMoveWidget(panel->grayPresetBtn[i], 2+(i*20), 34); WMSetButtonAction(panel->grayPresetBtn[i], grayPresetButtonCallback, panel); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); WMSetButtonImage(panel->grayPresetBtn[i], pixmap); WMSetButtonImagePosition(panel->grayPresetBtn[i], WIPImageOnly); WMReleasePixmap(pixmap); } RDestroyImage(image);    panel->rgbFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->rgbFrm, WRFlat); WMResizeWidget(panel->rgbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->rgbFrm, 0, 34);  panel->rgbMinL = WMCreateLabel(panel->rgbFrm); WMResizeWidget(panel->rgbMinL, 20, 10); WMMoveWidget(panel->rgbMinL, 2, 2); WMSetLabelText(panel->rgbMinL, "0"); WMSetLabelTextAlignment(panel->rgbMinL, WALeft); WMSetLabelTextColor(panel->rgbMinL, textcolor); WMSetLabelFont(panel->rgbMinL, panel->font8);  panel->rgbMaxL = WMCreateLabel(panel->rgbFrm); WMResizeWidget(panel->rgbMaxL, 40, 10); WMMoveWidget(panel->rgbMaxL, 104, 2); WMSetLabelText(panel->rgbMaxL, "255"); WMSetLabelTextAlignment(panel->rgbMaxL, WARight); WMSetLabelTextColor(panel->rgbMaxL, textcolor); WMSetLabelFont(panel->rgbMaxL, panel->font8);  panel->rgbRedS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbRedS, 141, 16); WMMoveWidget(panel->rgbRedS, 2, 14); WMSetSliderMinValue(panel->rgbRedS, 0); WMSetSliderMaxValue(panel->rgbRedS, 255); WMSetSliderKnobThickness(panel->rgbRedS, knobThickness); WMSetSliderAction(panel->rgbRedS, rgbSliderCallback, panel);  to.red = 255; to.green = 0; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->rgbRedS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Red", strlen("Red")); RDestroyImage(image); WMSetSliderImage(panel->rgbRedS, pixmap); WMReleasePixmap(pixmap);  panel->rgbRedT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbRedT, 40, 18); WMMoveWidget(panel->rgbRedT, 146, 13); WMSetTextFieldAlignment(panel->rgbRedT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->rgbRedT);   panel->rgbGreenS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbGreenS, 141, 16); WMMoveWidget(panel->rgbGreenS, 2, 36); WMSetSliderMinValue(panel->rgbGreenS, 0); WMSetSliderMaxValue(panel->rgbGreenS, 255); WMSetSliderKnobThickness(panel->rgbGreenS, knobThickness); WMSetSliderAction(panel->rgbGreenS, rgbSliderCallback, panel);  to.red = 0; to.green = 255; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->rgbGreenS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Green", strlen("Green")); RDestroyImage(image); WMSetSliderImage(panel->rgbGreenS, pixmap); WMReleasePixmap(pixmap);  panel->rgbGreenT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbGreenT, 40, 18); WMMoveWidget(panel->rgbGreenT, 146, 35); WMSetTextFieldAlignment(panel->rgbGreenT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->rgbGreenT);   panel->rgbBlueS = WMCreateSlider(panel->rgbFrm); WMResizeWidget(panel->rgbBlueS, 141, 16); WMMoveWidget(panel->rgbBlueS, 2, 58); WMSetSliderMinValue(panel->rgbBlueS, 0); WMSetSliderMaxValue(panel->rgbBlueS, 255); WMSetSliderKnobThickness(panel->rgbBlueS, knobThickness); WMSetSliderAction(panel->rgbBlueS, rgbSliderCallback, panel);  to.red = 0; to.green = 0; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->rgbBlueS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Blue", strlen("Blue")); RDestroyImage(image); WMSetSliderImage(panel->rgbBlueS, pixmap); WMReleasePixmap(pixmap);  panel->rgbBlueT = WMCreateTextField(panel->rgbFrm); WMResizeWidget(panel->rgbBlueT, 40, 18); WMMoveWidget(panel->rgbBlueT, 146, 57); WMSetTextFieldAlignment(panel->rgbBlueT, WALeft); WMAddNotificationObserver(rgbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->rgbBlueT);    panel->cmykFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->cmykFrm, WRFlat); WMResizeWidget(panel->cmykFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->cmykFrm, 0, 34);  panel->cmykMinL = WMCreateLabel(panel->cmykFrm); WMResizeWidget(panel->cmykMinL, 20, 10); WMMoveWidget(panel->cmykMinL, 2, 2); WMSetLabelText(panel->cmykMinL, "0"); WMSetLabelTextAlignment(panel->cmykMinL, WALeft); WMSetLabelTextColor(panel->cmykMinL, textcolor); WMSetLabelFont(panel->cmykMinL, panel->font8);  panel->cmykMaxL = WMCreateLabel(panel->cmykFrm); WMResizeWidget(panel->cmykMaxL, 40, 10); WMMoveWidget(panel->cmykMaxL, 104, 2); WMSetLabelText(panel->cmykMaxL, "100"); WMSetLabelTextAlignment(panel->cmykMaxL, WARight); WMSetLabelTextColor(panel->cmykMaxL, textcolor); WMSetLabelFont(panel->cmykMaxL, panel->font8);  panel->cmykCyanS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykCyanS, 141, 16); WMMoveWidget(panel->cmykCyanS, 2, 14); WMSetSliderMinValue(panel->cmykCyanS, 0); WMSetSliderMaxValue(panel->cmykCyanS, 100); WMSetSliderKnobThickness(panel->cmykCyanS, knobThickness); WMSetSliderAction(panel->cmykCyanS, cmykSliderCallback, panel);  from.red = 255; from.green = 255; from.blue = 255;  to.red = 0; to.green = 255; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykCyanS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Cyan", strlen("Cyan")); RDestroyImage(image); WMSetSliderImage(panel->cmykCyanS, pixmap); WMReleasePixmap(pixmap);  panel->cmykCyanT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykCyanT, 40, 18); WMMoveWidget(panel->cmykCyanT, 146, 13); WMSetTextFieldAlignment(panel->cmykCyanT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykCyanT);   panel->cmykMagentaS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykMagentaS, 141, 16); WMMoveWidget(panel->cmykMagentaS, 2, 36); WMSetSliderMinValue(panel->cmykMagentaS, 0); WMSetSliderMaxValue(panel->cmykMagentaS, 100); WMSetSliderKnobThickness(panel->cmykMagentaS, knobThickness); WMSetSliderAction(panel->cmykMagentaS, cmykSliderCallback, panel);  to.red = 255; to.green = 0; to.blue = 255;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykMagentaS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Magenta", strlen("Magenta")); RDestroyImage(image); WMSetSliderImage(panel->cmykMagentaS, pixmap); WMReleasePixmap(pixmap);  panel->cmykMagentaT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykMagentaT, 40, 18); WMMoveWidget(panel->cmykMagentaT, 146, 35); WMSetTextFieldAlignment(panel->cmykMagentaT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykMagentaT);   panel->cmykYellowS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykYellowS, 141, 16); WMMoveWidget(panel->cmykYellowS, 2, 58); WMSetSliderMinValue(panel->cmykYellowS, 0); WMSetSliderMaxValue(panel->cmykYellowS, 100); WMSetSliderKnobThickness(panel->cmykYellowS, knobThickness); WMSetSliderAction(panel->cmykYellowS, cmykSliderCallback, panel);  to.red = 255; to.green = 255; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykYellowS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Yellow", strlen("Yellow")); RDestroyImage(image); WMSetSliderImage(panel->cmykYellowS, pixmap); WMReleasePixmap(pixmap);  panel->cmykYellowT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykYellowT, 40, 18); WMMoveWidget(panel->cmykYellowT, 146, 57); WMSetTextFieldAlignment(panel->cmykYellowT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykYellowT);   panel->cmykBlackS = WMCreateSlider(panel->cmykFrm); WMResizeWidget(panel->cmykBlackS, 141, 16); WMMoveWidget(panel->cmykBlackS, 2, 80); WMSetSliderMinValue(panel->cmykBlackS, 0); WMSetSliderMaxValue(panel->cmykBlackS, 100); WMSetSliderValue(panel->cmykBlackS, 0); WMSetSliderKnobThickness(panel->cmykBlackS, knobThickness); WMSetSliderAction(panel->cmykBlackS, cmykSliderCallback, panel);  to.red = 0; to.green = 0; to.blue = 0;  image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL); pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0); W_PaintText(W_VIEW(panel->cmykBlackS), pixmap->pixmap, panel->font12, 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Black", strlen("Black")); RDestroyImage(image); WMSetSliderImage(panel->cmykBlackS, pixmap); WMReleasePixmap(pixmap);  panel->cmykBlackT = WMCreateTextField(panel->cmykFrm); WMResizeWidget(panel->cmykBlackT, 40, 18); WMMoveWidget(panel->cmykBlackT, 146, 79); WMSetTextFieldAlignment(panel->cmykBlackT, WALeft); WMAddNotificationObserver(cmykTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->cmykBlackT);    panel->hsbFrm = WMCreateFrame(panel->slidersFrm); WMSetFrameRelief(panel->hsbFrm, WRFlat); WMResizeWidget(panel->hsbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32); WMMoveWidget(panel->hsbFrm, 0, 34);  panel->hsbHueS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbHueS, 141, 16); WMMoveWidget(panel->hsbHueS, 2, 14); WMSetSliderMinValue(panel->hsbHueS, 0); WMSetSliderMaxValue(panel->hsbHueS, 359); WMSetSliderKnobThickness(panel->hsbHueS, knobThickness); WMSetSliderAction(panel->hsbHueS, hsbSliderCallback, panel);  panel->hsbHueT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbHueT, 40, 18); WMMoveWidget(panel->hsbHueT, 146, 13); WMSetTextFieldAlignment(panel->hsbHueT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->hsbHueT);   panel->hsbSaturationS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbSaturationS, 141, 16); WMMoveWidget(panel->hsbSaturationS, 2, 36); WMSetSliderMinValue(panel->hsbSaturationS, 0); WMSetSliderMaxValue(panel->hsbSaturationS, 100); WMSetSliderKnobThickness(panel->hsbSaturationS, knobThickness); WMSetSliderAction(panel->hsbSaturationS, hsbSliderCallback, panel);  panel->hsbSaturationT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbSaturationT, 40, 18); WMMoveWidget(panel->hsbSaturationT, 146, 35); WMSetTextFieldAlignment(panel->hsbSaturationT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->hsbSaturationT);   panel->hsbBrightnessS = WMCreateSlider(panel->hsbFrm); WMResizeWidget(panel->hsbBrightnessS, 141, 16); WMMoveWidget(panel->hsbBrightnessS, 2, 58); WMSetSliderMinValue(panel->hsbBrightnessS, 0); WMSetSliderMaxValue(panel->hsbBrightnessS, 100); WMSetSliderKnobThickness(panel->hsbBrightnessS, knobThickness); WMSetSliderAction(panel->hsbBrightnessS, hsbSliderCallback, panel);  panel->hsbBrightnessT = WMCreateTextField(panel->hsbFrm); WMResizeWidget(panel->hsbBrightnessT, 40, 18); WMMoveWidget(panel->hsbBrightnessT, 146, 57); WMSetTextFieldAlignment(panel->hsbBrightnessT, WALeft); WMAddNotificationObserver(hsbTextFieldCallback, panel, \ WMTextDidEndEditingNotification, panel->hsbBrightnessT);    WMReleaseColor(textcolor);   panel->customPaletteFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->customPaletteFrm, WRFlat); WMResizeWidget(panel->customPaletteFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->customPaletteFrm, 5, 80);  panel->customPaletteHistoryBtn = WMCreatePopUpButton(panel->customPaletteFrm); WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, "Spectrum"); WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, WMGetPopUpButtonNumberOfItems(panel->customPaletteHistoryBtn)-1); WMSetPopUpButtonAction(panel->customPaletteHistoryBtn, customPaletteHistoryCallback, panel); WMResizeWidget(panel->customPaletteHistoryBtn, PWIDTH - 8, 20); WMMoveWidget(panel->customPaletteHistoryBtn, 0, 0);  panel->customPaletteContentFrm = WMCreateFrame(panel->customPaletteFrm); WMSetFrameRelief(panel->customPaletteContentFrm, WRSunken); WMResizeWidget(panel->customPaletteContentFrm, PWIDTH - 8, PHEIGHT - 156); WMMoveWidget(panel->customPaletteContentFrm, 0, 23);  panel->customPaletteContentView = W_CreateView(W_VIEW(panel->customPaletteContentFrm));  W_ResizeView(panel->customPaletteContentView, customPaletteWidth, customPaletteHeight); W_MoveView(panel->customPaletteContentView, 2, 2);   WMCreateEventHandler(panel->customPaletteContentView, ButtonPressMask|ButtonReleaseMask|EnterWindowMask |LeaveWindowMask|ButtonMotionMask, customPaletteHandleActionEvents, panel);  WMCreateEventHandler(panel->customPaletteContentView, ExposureMask, customPaletteHandleEvents, panel);  panel->customPaletteMenuBtn = WMCreatePopUpButton(panel->customPaletteFrm); WMSetPopUpButtonPullsDown(panel->customPaletteMenuBtn, 1); WMSetPopUpButtonText(panel->customPaletteMenuBtn, "Palette"); WMSetPopUpButtonAction(panel->customPaletteMenuBtn, customPaletteMenuCallback, panel); WMResizeWidget(panel->customPaletteMenuBtn, PWIDTH - 8, 20); WMMoveWidget(panel->customPaletteMenuBtn, 0, PHEIGHT - 130);  WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "New from File...");         WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Rename...");                 WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Remove");                     WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Copy");                         WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "New from Clipboard");      WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 1, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 2, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 3, 0); WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 4, 0);  customRenderSpectrum(panel); panel->currentPalette = 0;    panel->colorListFrm = WMCreateFrame(panel->win); WMSetFrameRelief(panel->colorListFrm, WRFlat); WMResizeWidget(panel->colorListFrm, PWIDTH - 8, PHEIGHT - 80 - 26); WMMoveWidget(panel->colorListFrm, 5, 80);  panel->colorListHistoryBtn = WMCreatePopUpButton(panel->colorListFrm); WMAddPopUpButtonItem(panel->colorListHistoryBtn, "X11-Colors"); WMSetPopUpButtonSelectedItem(panel->colorListHistoryBtn, WMGetPopUpButtonNumberOfItems(panel->colorListHistoryBtn)-1);  WMResizeWidget(panel->colorListHistoryBtn, PWIDTH - 8, 20); WMMoveWidget(panel->colorListHistoryBtn, 0, 0);  panel->colorListContentLst = WMCreateList(panel->colorListFrm); WMSetListAction(panel->colorListContentLst, colorListSelect, panel); WMSetListUserDrawProc(panel->colorListContentLst, colorListPaintItem); WMResizeWidget(panel->colorListContentLst, PWIDTH - 8, PHEIGHT - 156); WMMoveWidget(panel->colorListContentLst, 0, 23); WMHangData(panel->colorListContentLst, panel);  panel->colorListColorMenuBtn = WMCreatePopUpButton(panel->colorListFrm); WMSetPopUpButtonPullsDown(panel->colorListColorMenuBtn, 1); WMSetPopUpButtonText(panel->colorListColorMenuBtn, "Color");  WMResizeWidget(panel->colorListColorMenuBtn, (PWIDTH - 16)/2, 20); WMMoveWidget(panel->colorListColorMenuBtn, 0, PHEIGHT - 130);  panel->colorListListMenuBtn = WMCreatePopUpButton(panel->colorListFrm); WMSetPopUpButtonPullsDown(panel->colorListListMenuBtn, 1); WMSetPopUpButtonText(panel->colorListListMenuBtn, "List");  WMResizeWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2, 20); WMMoveWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2 + 8, PHEIGHT - 130);   WMRealizeWidget(panel->win); WMMapSubwidgets(panel->win);  WMMapSubwidgets(panel->wheelFrm); WMMapSubwidgets(panel->slidersFrm); WMMapSubwidgets(panel->grayFrm); WMMapSubwidgets(panel->rgbFrm); WMMapSubwidgets(panel->cmykFrm); WMMapSubwidgets(panel->hsbFrm); WMMapSubwidgets(panel->customPaletteFrm); WMMapSubwidgets(panel->customPaletteContentFrm); WMMapSubwidgets(panel->colorListFrm);  readConfiguration(panel); readXColors(panel);  return panel;
context: makeColorPanel(WMScreen *scrPtr, char *name){	WMColorPanel	*panel;	RImage		*image;	WMPixmap	*pixmap;	RColor		from;	RColor		to;	int			i;	int			x,y;		globalFont = WMSystemFontOfSize(scrPtr, 12);	panel = wmalloc(sizeof(WMColorPanel));	memset(panel, 0, sizeof(WMColorPanel));		panel->win = WMCreateWindowWithStyle(scrPtr, name, WMTitledWindowMask | WMClosableWindowMask | WMResizableWindowMask);	WMResizeWidget(panel->win, PWIDTH, PHEIGHT);	WMSetWindowTitle(panel->win, "Colors");		/* Set Default ColorPanel Mode(s) */	panel->mode = WMWheelModeColorPanel;	panel->lastChanged = WMWheelModeColorPanel;	panel->slidersmode = WMRGBModeColorPanel;	panel->configurationPath = wstrappend(wusergnusteppath(), "/Library/Colors/");		/* Some Generic Purpose Widgets */	panel->colorWell = WMCreateColorWell(panel->win);	WMResizeWidget(panel->colorWell, 134, 36);	WSetColorWellBordered(panel->colorWell, False);	WMMoveWidget(panel->colorWell, 56, 4);	panel->magnifyBtn = WMCreateCommandButton(panel->win);	WMResizeWidget(panel->magnifyBtn, 46, 36);	WMMoveWidget(panel->magnifyBtn, 6,4);	WMSetButtonImagePosition(panel->magnifyBtn, WIPImageOnly);	WMSetButtonImage(panel->magnifyBtn, scrPtr->magnifyIcon);	WMSetButtonAltImage(panel->magnifyBtn, scrPtr->magnifyAltIcon);		panel->wheelBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->wheelBtn, 46, 32);	WMMoveWidget(panel->wheelBtn, 6, 44);	WMSetButtonAction(panel->wheelBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->wheelBtn, WIPImageOnly);	WMSetButtonImage(panel->wheelBtn, scrPtr->wheelIcon);	WMSetButtonAltImage(panel->wheelBtn, scrPtr->wheelAltIcon);	panel->slidersBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->slidersBtn, 46, 32);	WMMoveWidget(panel->slidersBtn, 52, 44);	WMSetButtonAction(panel->slidersBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->slidersBtn, WIPImageOnly);	WMSetButtonImage(panel->slidersBtn, scrPtr->rgbIcon);	WMSetButtonAltImage(panel->slidersBtn, scrPtr->rgbAltIcon);		panel->customPaletteBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->customPaletteBtn, 46, 32);	WMMoveWidget(panel->customPaletteBtn, 98, 44);	WMSetButtonAction(panel->customPaletteBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->customPaletteBtn, WIPImageOnly);	WMSetButtonImage(panel->customPaletteBtn, scrPtr->customPaletteIcon);	WMSetButtonAltImage(panel->customPaletteBtn, scrPtr->customPaletteAltIcon);	panel->colorListBtn = WMCreateCustomButton(panel->win, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->colorListBtn, 46, 32);	WMMoveWidget(panel->colorListBtn, 144, 44);	WMSetButtonAction(panel->colorListBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->colorListBtn, WIPImageOnly);	WMSetButtonImage(panel->colorListBtn, scrPtr->colorListIcon);	WMSetButtonAltImage(panel->colorListBtn, scrPtr->colorListAltIcon);		/* Let's Group some of them together */	WMGroupButtons(panel->wheelBtn, panel->slidersBtn);	WMGroupButtons(panel->wheelBtn, panel->customPaletteBtn);	WMGroupButtons(panel->wheelBtn, panel->colorListBtn);		/* Widgets for the ColorWheel Panel */	panel->wheelFrm = WMCreateFrame(panel->win);	WMSetFrameRelief(panel->wheelFrm, WRFlat);	WMResizeWidget(panel->wheelFrm, PWIDTH - 8, PHEIGHT - 80 - 26);	WMMoveWidget(panel->wheelFrm, 5, 80);	panel->wheelView = W_CreateView(W_VIEW(panel->wheelFrm));	/* XXX Can we create a view ? */	W_ResizeView(panel->wheelView, colorWheelSize+4, colorWheelSize+4);	W_MoveView(panel->wheelView, 0, 0);	/* Create an event handler to handle expose/click events in the ColorWheel */	WMCreateEventHandler(panel->wheelView, ButtonPressMask|ButtonReleaseMask|EnterWindowMask			|LeaveWindowMask|ButtonMotionMask, wheelHandleActionEvents, panel);	WMCreateEventHandler(panel->wheelView, ExposureMask, wheelHandleEvents, panel);	panel->wheelBrightnessS = WMCreateSlider(panel->wheelFrm);	WMResizeWidget(panel->wheelBrightnessS, 16, 153);	WMMoveWidget(panel->wheelBrightnessS, 5+colorWheelSize+14, 1);	WMSetSliderMinValue(panel->wheelBrightnessS, 0);	WMSetSliderMaxValue(panel->wheelBrightnessS, 255);	WMSetSliderAction(panel->wheelBrightnessS, wheelBrightnessSliderCallback, panel);	WMSetSliderKnobThickness(panel->wheelBrightnessS, knobThickness);		/* Widgets for the Slider Panels */	panel->slidersFrm = WMCreateFrame(panel->win);	WMSetFrameRelief(panel->slidersFrm, WRFlat);	WMResizeWidget(panel->slidersFrm, PWIDTH - 8, PHEIGHT - 80 - 26);	WMMoveWidget(panel->slidersFrm, 4, 80);	panel->seperatorFrm = WMCreateFrame(panel->slidersFrm);	WMSetFrameRelief(panel->seperatorFrm, WRPushed);	WMResizeWidget(panel->seperatorFrm, PWIDTH - 8, 2);	WMMoveWidget(panel->seperatorFrm, 0, 1);	panel->grayBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->grayBtn, 46, 24);	WMMoveWidget(panel->grayBtn, 1, 8);	WMSetButtonAction(panel->grayBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->grayBtn, WIPImageOnly);	WMSetButtonImage(panel->grayBtn, scrPtr->grayIcon);	WMSetButtonAltImage(panel->grayBtn, scrPtr->grayAltIcon);	panel->rgbBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->rgbBtn, 46, 24);	WMMoveWidget(panel->rgbBtn, 47, 8);	WMSetButtonAction(panel->rgbBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->rgbBtn, WIPImageOnly);	WMSetButtonImage(panel->rgbBtn, scrPtr->rgbIcon);	WMSetButtonAltImage(panel->rgbBtn, scrPtr->rgbAltIcon);		panel->cmykBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->cmykBtn, 46, 24);	WMMoveWidget(panel->cmykBtn, 93, 8);	WMSetButtonAction(panel->cmykBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->cmykBtn, WIPImageOnly);	WMSetButtonImage(panel->cmykBtn, scrPtr->cmykIcon);	WMSetButtonAltImage(panel->cmykBtn, scrPtr->cmykAltIcon);		panel->hsbBtn = WMCreateCustomButton(panel->slidersFrm, WBBStateLightMask|WBBStateChangeMask);	WMResizeWidget(panel->hsbBtn, 46, 24);	WMMoveWidget(panel->hsbBtn, 139, 8);	WMSetButtonAction(panel->hsbBtn, modeButtonCallback, panel);	WMSetButtonImagePosition(panel->hsbBtn, WIPImageOnly);	WMSetButtonImage(panel->hsbBtn, scrPtr->hsbIcon);	WMSetButtonAltImage(panel->hsbBtn, scrPtr->hsbAltIcon);		/* Let's Group the Slider Panel Buttons Together */	WMGroupButtons(panel->grayBtn, panel->rgbBtn);	WMGroupButtons(panel->grayBtn, panel->cmykBtn);	WMGroupButtons(panel->grayBtn, panel->hsbBtn);			/* Widgets for GrayScale Panel */		panel->grayFrm = WMCreateFrame(panel->slidersFrm);		WMSetFrameRelief(panel->grayFrm, WRFlat);		WMResizeWidget(panel->grayFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32);		WMMoveWidget(panel->grayFrm, 0, 34);				panel->grayMinL = WMCreateLabel(panel->grayFrm);		WMResizeWidget(panel->grayMinL, 20, 10);		WMMoveWidget(panel->grayMinL, 2, 2);		WMSetLabelText(panel->grayMinL, "0");		WMSetLabelTextAlignment(panel->grayMinL, WALeft);		WMSetLabelTextColor(panel->grayMinL, WMDarkGrayColor(scrPtr));		WMSetLabelFont(panel->grayMinL, WMSystemFontOfSize(scrPtr, 8));				panel->grayMaxL = WMCreateLabel(panel->grayFrm);		WMResizeWidget(panel->grayMaxL, 40, 10);		WMMoveWidget(panel->grayMaxL, 104, 2);		WMSetLabelText(panel->grayMaxL, "100");		WMSetLabelTextAlignment(panel->grayMaxL, WARight);		WMSetLabelTextColor(panel->grayMaxL, WMDarkGrayColor(scrPtr));		WMSetLabelFont(panel->grayMaxL, WMSystemFontOfSize(scrPtr, 8));				panel->grayBrightnessS = WMCreateSlider(panel->grayFrm);		WMResizeWidget(panel->grayBrightnessS, 141, 16);		WMMoveWidget(panel->grayBrightnessS, 2, 14);		WMSetSliderMinValue(panel->grayBrightnessS, 0);		WMSetSliderMaxValue(panel->grayBrightnessS, 100);		WMSetSliderKnobThickness(panel->grayBrightnessS, knobThickness);		WMSetSliderAction(panel->grayBrightnessS, grayBrightnessSliderCallback, panel);				from.red = 0;		from.green = 0;		from.blue = 0;				to.red = 255;		to.green = 255;		to.blue = 255;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		RDestroyImage(image);		W_PaintText(W_VIEW(panel->grayBrightnessS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Brightness", strlen("Brightness"));		WMSetSliderImage(panel->grayBrightnessS, pixmap);		WMReleasePixmap(pixmap);				panel->grayBrightnessT = WMCreateTextField(panel->grayFrm);		WMResizeWidget(panel->grayBrightnessT, 40, 18);		WMMoveWidget(panel->grayBrightnessT, 146, 13);		WMSetTextFieldAlignment(panel->grayBrightnessT, WALeft);		WMAddNotificationObserver(grayBrightnessTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->grayBrightnessT);			image = RCreateImage(13,13,False);		for (i=0; i < 7; i++) {			for (x=0; x < 13; x++) {				for (y=0; y < 13; y++) {					image->data[0][y*13+x] = 255/6*i;					image->data[1][y*13+x] = 255/6*i;					image->data[2][y*13+x] = 255/6*i;				}			}			panel->grayPresetBtn[i] = WMCreateCommandButton(panel->grayFrm);			WMResizeWidget(panel->grayPresetBtn[i], 20, 24);			WMMoveWidget(panel->grayPresetBtn[i], 2+(i*20), 34);			WMSetButtonAction(panel->grayPresetBtn[i], grayPresetButtonCallback, panel);		    pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);			WMSetButtonImage(panel->grayPresetBtn[i], pixmap);			WMSetButtonImagePosition(panel->grayPresetBtn[i], WIPImageOnly);			WMReleasePixmap(pixmap);			}		RDestroyImage(image);		/* End of GrayScale Panel */				/* Widgets for RGB Panel */		panel->rgbFrm = WMCreateFrame(panel->slidersFrm);		WMSetFrameRelief(panel->rgbFrm, WRFlat);		WMResizeWidget(panel->rgbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32);		WMMoveWidget(panel->rgbFrm, 0, 34);				panel->rgbMinL = WMCreateLabel(panel->rgbFrm);		WMResizeWidget(panel->rgbMinL, 20, 10);		WMMoveWidget(panel->rgbMinL, 2, 2);		WMSetLabelText(panel->rgbMinL, "0");		WMSetLabelTextAlignment(panel->rgbMinL, WALeft);		WMSetLabelTextColor(panel->rgbMinL, WMDarkGrayColor(scrPtr));		WMSetLabelFont(panel->rgbMinL, WMSystemFontOfSize(scrPtr, 8));				panel->rgbMaxL = WMCreateLabel(panel->rgbFrm);		WMResizeWidget(panel->rgbMaxL, 40, 10);		WMMoveWidget(panel->rgbMaxL, 104, 2);		WMSetLabelText(panel->rgbMaxL, "255");		WMSetLabelTextAlignment(panel->rgbMaxL, WARight);		WMSetLabelTextColor(panel->rgbMaxL, WMDarkGrayColor(scrPtr));		WMSetLabelFont(panel->rgbMaxL, WMSystemFontOfSize(scrPtr, 8));				panel->rgbRedS = WMCreateSlider(panel->rgbFrm);		WMResizeWidget(panel->rgbRedS, 141, 16);		WMMoveWidget(panel->rgbRedS, 2, 14);		WMSetSliderMinValue(panel->rgbRedS, 0);		WMSetSliderMaxValue(panel->rgbRedS, 255);		WMSetSliderKnobThickness(panel->rgbRedS, knobThickness);		WMSetSliderAction(panel->rgbRedS, rgbSliderCallback, panel);				to.red = 255;		to.green = 0;		to.blue = 0;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->rgbRedS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Red", strlen("Red"));		RDestroyImage(image);		WMSetSliderImage(panel->rgbRedS, pixmap);		WMReleasePixmap(pixmap);				panel->rgbRedT = WMCreateTextField(panel->rgbFrm);		WMResizeWidget(panel->rgbRedT, 40, 18);		WMMoveWidget(panel->rgbRedT, 146, 13);		WMSetTextFieldAlignment(panel->rgbRedT, WALeft);		WMAddNotificationObserver(rgbTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->rgbRedT);				panel->rgbGreenS = WMCreateSlider(panel->rgbFrm);		WMResizeWidget(panel->rgbGreenS, 141, 16);		WMMoveWidget(panel->rgbGreenS, 2, 36);		WMSetSliderMinValue(panel->rgbGreenS, 0);		WMSetSliderMaxValue(panel->rgbGreenS, 255);		WMSetSliderKnobThickness(panel->rgbGreenS, knobThickness);		WMSetSliderAction(panel->rgbGreenS, rgbSliderCallback, panel);				to.red = 0;		to.green = 255;		to.blue = 0;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->rgbGreenS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Green", strlen("Green"));		RDestroyImage(image);		WMSetSliderImage(panel->rgbGreenS, pixmap);		WMReleasePixmap(pixmap);				panel->rgbGreenT = WMCreateTextField(panel->rgbFrm);		WMResizeWidget(panel->rgbGreenT, 40, 18);		WMMoveWidget(panel->rgbGreenT, 146, 35);		WMSetTextFieldAlignment(panel->rgbGreenT, WALeft);		WMAddNotificationObserver(rgbTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->rgbGreenT);			panel->rgbBlueS = WMCreateSlider(panel->rgbFrm);		WMResizeWidget(panel->rgbBlueS, 141, 16);		WMMoveWidget(panel->rgbBlueS, 2, 58);		WMSetSliderMinValue(panel->rgbBlueS, 0);		WMSetSliderMaxValue(panel->rgbBlueS, 255);		WMSetSliderKnobThickness(panel->rgbBlueS, knobThickness);		WMSetSliderAction(panel->rgbBlueS, rgbSliderCallback, panel);			to.red = 0;		to.green = 0;		to.blue = 255;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->rgbBlueS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->white), False, "Blue", strlen("Blue"));		RDestroyImage(image);		WMSetSliderImage(panel->rgbBlueS, pixmap);		WMReleasePixmap(pixmap);				panel->rgbBlueT = WMCreateTextField(panel->rgbFrm);		WMResizeWidget(panel->rgbBlueT, 40, 18);		WMMoveWidget(panel->rgbBlueT, 146, 57);		WMSetTextFieldAlignment(panel->rgbBlueT, WALeft);		WMAddNotificationObserver(rgbTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->rgbBlueT);		/* End of RGB Panel */		/* Widgets for CMYK Panel */		panel->cmykFrm = WMCreateFrame(panel->slidersFrm);		WMSetFrameRelief(panel->cmykFrm, WRFlat);		WMResizeWidget(panel->cmykFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32);		WMMoveWidget(panel->cmykFrm, 0, 34);					panel->cmykMinL = WMCreateLabel(panel->cmykFrm);		WMResizeWidget(panel->cmykMinL, 20, 10);		WMMoveWidget(panel->cmykMinL, 2, 2);		WMSetLabelText(panel->cmykMinL, "0");		WMSetLabelTextAlignment(panel->cmykMinL, WALeft);		WMSetLabelTextColor(panel->cmykMinL, WMDarkGrayColor(scrPtr));		WMSetLabelFont(panel->cmykMinL, WMSystemFontOfSize(scrPtr, 8));				panel->cmykMaxL = WMCreateLabel(panel->cmykFrm);		WMResizeWidget(panel->cmykMaxL, 40, 10);		WMMoveWidget(panel->cmykMaxL, 104, 2);		WMSetLabelText(panel->cmykMaxL, "100");		WMSetLabelTextAlignment(panel->cmykMaxL, WARight);		WMSetLabelTextColor(panel->cmykMaxL, WMDarkGrayColor(scrPtr));		WMSetLabelFont(panel->cmykMaxL, WMSystemFontOfSize(scrPtr, 8));				panel->cmykCyanS = WMCreateSlider(panel->cmykFrm);		WMResizeWidget(panel->cmykCyanS, 141, 16);		WMMoveWidget(panel->cmykCyanS, 2, 14);		WMSetSliderMinValue(panel->cmykCyanS, 0);		WMSetSliderMaxValue(panel->cmykCyanS, 100);		WMSetSliderKnobThickness(panel->cmykCyanS, knobThickness);		WMSetSliderAction(panel->cmykCyanS, cmykSliderCallback, panel);				from.red = 255;		from.green = 255;		from.blue = 255;				to.red = 0;		to.green = 255;		to.blue = 255;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->cmykCyanS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Cyan", strlen("Cyan"));		RDestroyImage(image);		WMSetSliderImage(panel->cmykCyanS, pixmap);		WMReleasePixmap(pixmap);				panel->cmykCyanT = WMCreateTextField(panel->cmykFrm);		WMResizeWidget(panel->cmykCyanT, 40, 18);		WMMoveWidget(panel->cmykCyanT, 146, 13);		WMSetTextFieldAlignment(panel->cmykCyanT, WALeft);		WMAddNotificationObserver(cmykTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->cmykCyanT);				panel->cmykMagentaS = WMCreateSlider(panel->cmykFrm);		WMResizeWidget(panel->cmykMagentaS, 141, 16);		WMMoveWidget(panel->cmykMagentaS, 2, 36);		WMSetSliderMinValue(panel->cmykMagentaS, 0);		WMSetSliderMaxValue(panel->cmykMagentaS, 100);		WMSetSliderKnobThickness(panel->cmykMagentaS, knobThickness);		WMSetSliderAction(panel->cmykMagentaS, cmykSliderCallback, panel);				to.red = 255;		to.green = 0;		to.blue = 255;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->cmykMagentaS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Magenta", strlen("Magenta"));		RDestroyImage(image);		WMSetSliderImage(panel->cmykMagentaS, pixmap);		WMReleasePixmap(pixmap);				panel->cmykMagentaT = WMCreateTextField(panel->cmykFrm);		WMResizeWidget(panel->cmykMagentaT, 40, 18);		WMMoveWidget(panel->cmykMagentaT, 146, 35);		WMSetTextFieldAlignment(panel->cmykMagentaT, WALeft);		WMAddNotificationObserver(cmykTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->cmykMagentaT);			panel->cmykYellowS = WMCreateSlider(panel->cmykFrm);		WMResizeWidget(panel->cmykYellowS, 141, 16);		WMMoveWidget(panel->cmykYellowS, 2, 58);		WMSetSliderMinValue(panel->cmykYellowS, 0);		WMSetSliderMaxValue(panel->cmykYellowS, 100);		WMSetSliderKnobThickness(panel->cmykYellowS, knobThickness);		WMSetSliderAction(panel->cmykYellowS, cmykSliderCallback, panel);			to.red = 255;		to.green = 255;		to.blue = 0;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->cmykYellowS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Yellow", strlen("Yellow"));		RDestroyImage(image);		WMSetSliderImage(panel->cmykYellowS, pixmap);		WMReleasePixmap(pixmap);				panel->cmykYellowT = WMCreateTextField(panel->cmykFrm);		WMResizeWidget(panel->cmykYellowT, 40, 18);		WMMoveWidget(panel->cmykYellowT, 146, 57);		WMSetTextFieldAlignment(panel->cmykYellowT, WALeft);		WMAddNotificationObserver(cmykTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->cmykYellowT);			panel->cmykBlackS = WMCreateSlider(panel->cmykFrm);		WMResizeWidget(panel->cmykBlackS, 141, 16);		WMMoveWidget(panel->cmykBlackS, 2, 80);		WMSetSliderMinValue(panel->cmykBlackS, 0);		WMSetSliderMaxValue(panel->cmykBlackS, 100);		WMSetSliderValue(panel->cmykBlackS, 0);		WMSetSliderKnobThickness(panel->cmykBlackS, knobThickness);		WMSetSliderAction(panel->cmykBlackS, cmykSliderCallback, panel);			to.red = 0;		to.green = 0;		to.blue = 0;				image = RRenderGradient(141, 16, &from, &to, RGRD_HORIZONTAL);		pixmap = WMCreatePixmapFromRImage(scrPtr, image, 0);		W_PaintText(W_VIEW(panel->cmykBlackS), pixmap->pixmap, WMSystemFontOfSize(scrPtr, 12), 2, 0, 100, WALeft, W_GC(scrPtr->black), False, "Black", strlen("Black"));		RDestroyImage(image);		WMSetSliderImage(panel->cmykBlackS, pixmap);		WMReleasePixmap(pixmap);				panel->cmykBlackT = WMCreateTextField(panel->cmykFrm);		WMResizeWidget(panel->cmykBlackT, 40, 18);		WMMoveWidget(panel->cmykBlackT, 146, 79);		WMSetTextFieldAlignment(panel->cmykBlackT, WALeft);		WMAddNotificationObserver(cmykTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->cmykBlackT);		/* End of CMYK Panel */		/* Widgets for HSB Panel */		panel->hsbFrm = WMCreateFrame(panel->slidersFrm);		WMSetFrameRelief(panel->hsbFrm, WRFlat);		WMResizeWidget(panel->hsbFrm, PWIDTH - 8, PHEIGHT - 80 - 26 - 32);		WMMoveWidget(panel->hsbFrm, 0, 34);		panel->hsbHueS = WMCreateSlider(panel->hsbFrm);		WMResizeWidget(panel->hsbHueS, 141, 16);		WMMoveWidget(panel->hsbHueS, 2, 14);		WMSetSliderMinValue(panel->hsbHueS, 0);		WMSetSliderMaxValue(panel->hsbHueS, 359);		WMSetSliderKnobThickness(panel->hsbHueS, knobThickness);		WMSetSliderAction(panel->hsbHueS, hsbSliderCallback, panel);				panel->hsbHueT = WMCreateTextField(panel->hsbFrm);		WMResizeWidget(panel->hsbHueT, 40, 18);		WMMoveWidget(panel->hsbHueT, 146, 13);		WMSetTextFieldAlignment(panel->hsbHueT, WALeft);		WMAddNotificationObserver(hsbTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->hsbHueT);				panel->hsbSaturationS = WMCreateSlider(panel->hsbFrm);		WMResizeWidget(panel->hsbSaturationS, 141, 16);		WMMoveWidget(panel->hsbSaturationS, 2, 36);		WMSetSliderMinValue(panel->hsbSaturationS, 0);		WMSetSliderMaxValue(panel->hsbSaturationS, 100);		WMSetSliderKnobThickness(panel->hsbSaturationS, knobThickness);		WMSetSliderAction(panel->hsbSaturationS, hsbSliderCallback, panel);				panel->hsbSaturationT = WMCreateTextField(panel->hsbFrm);		WMResizeWidget(panel->hsbSaturationT, 40, 18);		WMMoveWidget(panel->hsbSaturationT, 146, 35);		WMSetTextFieldAlignment(panel->hsbSaturationT, WALeft);		WMAddNotificationObserver(hsbTextFieldCallback, panel, \					WMTextDidEndEditingNotification, panel->hsbSaturationT);			panel->hsbBrightnessS = WMCreateSlider(panel->hsbFrm);		WMResizeWidget(panel->hsbBrightnessS, 141, 16);		WMMoveWidget(panel->hsbBrightnessS, 2, 58);		WMSetSliderMinValue(panel->hsbBrightnessS, 0);		WMSetSliderMaxValue(panel->hsbBrightnessS, 100);		WMSetSliderKnobThickness(panel->hsbBrightnessS, knobThickness);		WMSetSliderAction(panel->hsbBrightnessS, hsbSliderCallback, panel);				panel->hsbBrightnessT = WMCreateTextField(panel->hsbFrm);		WMResizeWidget(panel->hsbBrightnessT, 40, 18);		WMMoveWidget(panel->hsbBrightnessT, 146, 57);		WMSetTextFieldAlignment(panel->hsbBrightnessT, WALeft);		WMAddNotificationObserver(hsbTextFieldCallback, panel, \			WMTextDidEndEditingNotification, panel->hsbBrightnessT);		/* End of HSB Panel */	/* Widgets for the CustomPalette Panel */	panel->customPaletteFrm = WMCreateFrame(panel->win);	WMSetFrameRelief(panel->customPaletteFrm, WRFlat);	WMResizeWidget(panel->customPaletteFrm, PWIDTH - 8, PHEIGHT - 80 - 26);	WMMoveWidget(panel->customPaletteFrm, 5, 80);	panel->customPaletteHistoryBtn = WMCreatePopUpButton(panel->customPaletteFrm);	WMAddPopUpButtonItem(panel->customPaletteHistoryBtn, "Spectrum");	WMSetPopUpButtonSelectedItem(panel->customPaletteHistoryBtn, WMGetPopUpButtonNumberOfItems(panel->customPaletteHistoryBtn)-1);	WMSetPopUpButtonAction(panel->customPaletteHistoryBtn, customPaletteHistoryCallback, panel);	WMResizeWidget(panel->customPaletteHistoryBtn, PWIDTH - 8, 20);	WMMoveWidget(panel->customPaletteHistoryBtn, 0, 0);		panel->customPaletteContentFrm = WMCreateFrame(panel->customPaletteFrm);	WMSetFrameRelief(panel->customPaletteContentFrm, WRSunken);	WMResizeWidget(panel->customPaletteContentFrm, PWIDTH - 8, PHEIGHT - 156);	WMMoveWidget(panel->customPaletteContentFrm, 0, 23);	panel->customPaletteContentView = W_CreateView(W_VIEW(panel->customPaletteContentFrm));	/* XXX Can we create a view ? */	W_ResizeView(panel->customPaletteContentView, customPaletteWidth, customPaletteHeight);	W_MoveView(panel->customPaletteContentView, 2, 2);	/* Create an event handler to handle expose/click events in the CustomPalette */	WMCreateEventHandler(panel->customPaletteContentView, ButtonPressMask|ButtonReleaseMask|EnterWindowMask			|LeaveWindowMask|ButtonMotionMask, customPaletteHandleActionEvents, panel);	WMCreateEventHandler(panel->customPaletteContentView, ExposureMask, customPaletteHandleEvents, panel);	panel->customPaletteMenuBtn = WMCreatePopUpButton(panel->customPaletteFrm);	WMSetPopUpButtonPullsDown(panel->customPaletteMenuBtn, 1);	WMSetPopUpButtonText(panel->customPaletteMenuBtn, "Palette");	WMSetPopUpButtonAction(panel->customPaletteMenuBtn, customPaletteMenuCallback, panel);	WMResizeWidget(panel->customPaletteMenuBtn, PWIDTH - 8, 20);	WMMoveWidget(panel->customPaletteMenuBtn, 0, PHEIGHT - 130);	WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "New from File...");		/* item 0 */	WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Rename...");				/* item 1 */	WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Remove");					/* item 2 */	WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "Copy");						/* item 3 */	WMAddPopUpButtonItem(panel->customPaletteMenuBtn, "New from Clipboard");	/* item 4 */	WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 1, 0);	WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 2, 0);	WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 3, 0);	WMSetPopUpButtonItemEnabled(panel->customPaletteMenuBtn, 4, 0);	customRenderSpectrum(panel);	panel->currentPalette = 0;	/* Widgets for the ColorList Panel */	panel->colorListFrm = WMCreateFrame(panel->win);	WMSetFrameRelief(panel->colorListFrm, WRFlat);	WMResizeWidget(panel->colorListFrm, PWIDTH - 8, PHEIGHT - 80 - 26);	WMMoveWidget(panel->colorListFrm, 5, 80);	panel->colorListHistoryBtn = WMCreatePopUpButton(panel->colorListFrm);	WMAddPopUpButtonItem(panel->colorListHistoryBtn, "X11-Colors");	WMSetPopUpButtonSelectedItem(panel->colorListHistoryBtn, WMGetPopUpButtonNumberOfItems(panel->colorListHistoryBtn)-1);//	WMSetPopUpButtonAction(panel->colorListHistoryBtn, colorListHistoryCallback, panel);	WMResizeWidget(panel->colorListHistoryBtn, PWIDTH - 8, 20);	WMMoveWidget(panel->colorListHistoryBtn, 0, 0);		panel->colorListContentLst = WMCreateList(panel->colorListFrm);	WMSetListAction(panel->colorListContentLst, colorListSelect, panel);	WMSetListUserDrawProc(panel->colorListContentLst, colorListPaintItem);	WMResizeWidget(panel->colorListContentLst, PWIDTH - 8, PHEIGHT - 156);	WMMoveWidget(panel->colorListContentLst, 0, 23);	panel->colorListColorMenuBtn = WMCreatePopUpButton(panel->colorListFrm);	WMSetPopUpButtonPullsDown(panel->colorListColorMenuBtn, 1);	WMSetPopUpButtonText(panel->colorListColorMenuBtn, "Color");//	WMSetPopUpButtonAction(panel->colorListColorMenuBtn, colorListColorMenuCallback, panel);	WMResizeWidget(panel->colorListColorMenuBtn, (PWIDTH - 16)/2, 20);	WMMoveWidget(panel->colorListColorMenuBtn, 0, PHEIGHT - 130);	panel->colorListListMenuBtn = WMCreatePopUpButton(panel->colorListFrm);	WMSetPopUpButtonPullsDown(panel->colorListListMenuBtn, 1);	WMSetPopUpButtonText(panel->colorListListMenuBtn, "List");//	WMSetPopUpButtonAction(panel->colorListListMenuBtn, colorListListMenuCallback, panel);	WMResizeWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2, 20);	WMMoveWidget(panel->colorListListMenuBtn, (PWIDTH - 16)/2 + 8, PHEIGHT - 130);	WMRealizeWidget(panel->win);	WMMapSubwidgets(panel->win);	WMMapSubwidgets(panel->wheelFrm);	WMMapSubwidgets(panel->slidersFrm);		WMMapSubwidgets(panel->grayFrm);		WMMapSubwidgets(panel->rgbFrm);		WMMapSubwidgets(panel->cmykFrm);		WMMapSubwidgets(panel->hsbFrm);	WMMapSubwidgets(panel->customPaletteFrm);		WMMapSubwidgets(panel->customPaletteContentFrm);	WMMapSubwidgets(panel->colorListFrm);	readConfiguration(panel);	readXColors(panel); 	return panel;}