WMPixmap *WMCreateScaledBlendedPixmapFromFile(WMScreen *scrPtr, const char *fileName, const RColor *color, unsigned int width, unsigned int height) { WMPixmap *pixPtr; RImage *image; image = RLoadImage(scrPtr->rcontext, fileName, 0); if (!image) return NULL; /* scale it if needed to fit in the specified box */ if ((width > 0) && (height > 0) && ((image->width > width) || (image->height > height))) { int new_width, new_height; RImage *new_image; new_width = image->width; new_height = image->height; if (new_width > width) { new_width = width; new_height = width * image->height / image->width; } if (new_height > height) { new_width = height * image->width / image->height; new_height = height; } new_image = RScaleImage(image, new_width, new_height); RReleaseImage(image); image = new_image; } RCombineImageWithColor(image, color); pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0); RReleaseImage(image); return pixPtr; }
static void createPanel(Panel *p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); char *buf1, *buf2; WMPixmap *icon, *altIcon; RImage *xis = NULL; int i; RContext *rc = WMScreenRContext(scr); WMFont *font = WMSystemFontOfSize(scr, 10); char *path; path = LocateImage(ARQUIVO_XIS); if (path) { xis = RLoadImage(rc, path, 0); if (!xis) wwarning(_("could not load image file %s"), path); wfree(path); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /*********** Icon Slide Speed **********/ panel->icoF = WMCreateFrame(panel->box); WMResizeWidget(panel->icoF, 212, 45); WMMoveWidget(panel->icoF, 15, 10); WMSetFrameTitle(panel->icoF, _("Icon Slide Speed")); /*********** Shade Animation Speed **********/ panel->shaF = WMCreateFrame(panel->box); WMResizeWidget(panel->shaF, 212, 45); WMMoveWidget(panel->shaF, 15, 65); WMSetFrameTitle(panel->shaF, _("Shade Animation Speed")); buf1 = wmalloc(strlen(SPEED_IMAGE) + 1); buf2 = wmalloc(strlen(SPEED_IMAGE_S) + 1); for (i = 0; i < 5; i++) { panel->icoB[i] = WMCreateCustomButton(panel->icoF, WBBStateChangeMask); panel->shaB[i] = WMCreateCustomButton(panel->shaF, WBBStateChangeMask); WMResizeWidget(panel->icoB[i], 40, 24); WMMoveWidget(panel->icoB[i], 2 + (40 * i), 15); WMResizeWidget(panel->shaB[i], 40, 24); WMMoveWidget(panel->shaB[i], 2 + (40 * i), 15); WMSetButtonBordered(panel->icoB[i], False); WMSetButtonImagePosition(panel->icoB[i], WIPImageOnly); if (i > 0) { WMGroupButtons(panel->icoB[0], panel->icoB[i]); } WMSetButtonBordered(panel->shaB[i], False); WMSetButtonImagePosition(panel->shaB[i], WIPImageOnly); if (i > 0) { WMGroupButtons(panel->shaB[0], panel->shaB[i]); } sprintf(buf1, SPEED_IMAGE, i); sprintf(buf2, SPEED_IMAGE_S, i); path = LocateImage(buf1); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->icoB[i], icon); WMSetButtonImage(panel->shaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } path = LocateImage(buf2); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonAltImage(panel->icoB[i], icon); WMSetButtonAltImage(panel->shaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } } wfree(buf1); wfree(buf2); WMMapSubwidgets(panel->icoF); WMMapSubwidgets(panel->shaF); /***************** Smoothed Scaling *****************/ panel->smoF = WMCreateFrame(panel->box); WMResizeWidget(panel->smoF, 94, 100); WMMoveWidget(panel->smoF, 420, 10); WMSetFrameTitle(panel->smoF, _("Smooth Scaling")); panel->smoB = WMCreateButton(panel->smoF, WBTToggle); WMResizeWidget(panel->smoB, 64, 64); WMMoveWidget(panel->smoB, 15, 23); WMSetButtonImagePosition(panel->smoB, WIPImageOnly); path = LocateImage(SMOOTH_IMAGE); if (path) { RImage *image, *scaled; image = RLoadImage(WMScreenRContext(scr), path, 0); wfree(path); scaled = RScaleImage(image, 61, 61); icon = WMCreatePixmapFromRImage(scr, scaled, 128); RReleaseImage(scaled); if (icon) { WMSetButtonImage(panel->smoB, icon); WMReleasePixmap(icon); } scaled = RSmoothScaleImage(image, 61, 61); icon = WMCreatePixmapFromRImage(scr, scaled, 128); RReleaseImage(scaled); if (icon) { WMSetButtonAltImage(panel->smoB, icon); WMReleasePixmap(icon); } RReleaseImage(image); } WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n" "the `pixelization' effect. This will slow\n" "down loading of background images considerably."), WMWidgetView(panel->smoB)); WMMapSubwidgets(panel->smoF); /***************** Titlebar Style Size ****************/ panel->titlF = WMCreateFrame(panel->box); WMResizeWidget(panel->titlF, 212, 97); WMMoveWidget(panel->titlF, 15, 120); WMSetFrameTitle(panel->titlF, _("Titlebar Style")); panel->oldsB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->oldsB, 60, 40); WMMoveWidget(panel->oldsB, 16, 32); WMSetButtonImagePosition(panel->oldsB, WIPImageOnly); path = LocateImage(OLDS_IMAGE); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->oldsB, icon); WMReleasePixmap(icon); } wfree(path); } panel->newsB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->newsB, 60, 40); WMMoveWidget(panel->newsB, 76, 32); WMSetButtonImagePosition(panel->newsB, WIPImageOnly); path = LocateImage(NEWS_IMAGE); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->newsB, icon); WMReleasePixmap(icon); } wfree(path); } panel->nextB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->nextB, 60, 40); WMMoveWidget(panel->nextB, 136, 32); WMSetButtonImagePosition(panel->nextB, WIPImageOnly); path = LocateImage(NEXT_IMAGE); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->nextB, icon); WMReleasePixmap(icon); } wfree(path); } WMGroupButtons(panel->newsB, panel->oldsB); WMGroupButtons(panel->newsB, panel->nextB); WMMapSubwidgets(panel->titlF); /**************** Features ******************/ panel->animF = WMCreateFrame(panel->box); WMResizeWidget(panel->animF, 173, 100); WMMoveWidget(panel->animF, 237, 10); WMSetFrameTitle(panel->animF, _("Animations")); panel->animB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->animB, 64, 64); WMMoveWidget(panel->animB, 15, 23); WMSetButtonFont(panel->animB, font); WMSetButtonText(panel->animB, _("Animations")); WMSetButtonImagePosition(panel->animB, WIPAbove); CreateImages(scr, rc, xis, ANIM_IMAGE, &altIcon, &icon); if (icon) { WMSetButtonImage(panel->animB, icon); WMReleasePixmap(icon); } if (altIcon) { WMSetButtonAltImage(panel->animB, altIcon); WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n" "for window miniaturization, shading etc."), WMWidgetView(panel->animB)); panel->supB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->supB, 64, 64); WMMoveWidget(panel->supB, 94, 23); WMSetButtonFont(panel->supB, font); WMSetButtonText(panel->supB, _("Superfluous")); WMSetButtonImagePosition(panel->supB, WIPAbove); CreateImages(scr, rc, xis, SUPERF_IMAGE, &altIcon, &icon); if (icon) { WMSetButtonImage(panel->supB, icon); WMReleasePixmap(icon); } if (altIcon) { WMSetButtonAltImage(panel->supB, altIcon); WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n" "animations. These include the `ghosting' of the\n" "dock when it's being moved to another side and\n" "the explosion animation when undocking icons."), WMWidgetView(panel->supB)); WMMapSubwidgets(panel->animF); /*********** Dithering **********/ panel->cmapSize = 4; panel->dithF = WMCreateFrame(panel->box); WMResizeWidget(panel->dithF, 277, 97); WMMoveWidget(panel->dithF, 237, 120); WMSetFrameTitle(panel->dithF, _("Dithering colormap for 8bpp")); WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n" "on displays that support only 8bpp (PseudoColor)."), WMWidgetView(panel->dithF)); panel->dithB = WMCreateSwitchButton(panel->dithF); WMResizeWidget(panel->dithB, 235, 32); WMMoveWidget(panel->dithB, 15, 15); WMSetButtonText(panel->dithB, _("Disable dithering in any visual/depth")); panel->dithL = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dithL, 75, 16); WMMoveWidget(panel->dithL, 98, 50); WMSetLabelTextAlignment(panel->dithL, WACenter); WMSetLabelText(panel->dithL, "64"); panel->dithS = WMCreateSlider(panel->dithF); WMResizeWidget(panel->dithS, 95, 16); WMMoveWidget(panel->dithS, 90, 65); WMSetSliderMinValue(panel->dithS, 2); WMSetSliderMaxValue(panel->dithS, 6); WMSetSliderContinuous(panel->dithS, True); WMSetSliderAction(panel->dithS, updateLabel, panel); panel->dith1L = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dith1L, 80, 35); WMMoveWidget(panel->dith1L, 5, 50); WMSetLabelTextAlignment(panel->dith1L, WACenter); WMSetLabelFont(panel->dith1L, font); WMSetLabelText(panel->dith1L, _("More colors for\napplications")); panel->dith2L = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dith2L, 80, 35); WMMoveWidget(panel->dith2L, 190, 50); WMSetLabelTextAlignment(panel->dith2L, WACenter); WMSetLabelFont(panel->dith2L, font); WMSetLabelText(panel->dith2L, _("More colors for\nWindow Maker")); WMMapSubwidgets(panel->dithF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); if (xis) RReleaseImage(xis); WMReleaseFont(font); showData(panel); }
color1.alpha = 255; RClearImage(image, &color1); break; case WTEX_PIXMAP: if (texture->pixmap.subtype == WTP_TILE) { image = RMakeTiledImage(texture->pixmap.pixmap, width, height); } else if (texture->pixmap.subtype == WTP_CENTER) { color1.red = texture->pixmap.normal.red >> 8; color1.green = texture->pixmap.normal.green >> 8; color1.blue = texture->pixmap.normal.blue >> 8; color1.alpha = 255; image = RMakeCenteredImage(texture->pixmap.pixmap, width, height, &color1); } else { image = RScaleImage(texture->pixmap.pixmap, width, height); } break; case WTEX_IGRADIENT: image = RRenderInterwovenGradient(width, height, texture->igradient.colors1, texture->igradient.thickness1, texture->igradient.colors2, texture->igradient.thickness2); break; case WTEX_HGRADIENT: subtype = RGRD_HORIZONTAL; goto render_gradient; case WTEX_VGRADIENT:
static void applyImage(RContext * rc, BackgroundTexture * texture, RImage * image, char type, int x, int y, int width, int height) { int w, h; Bool fimage = False; switch (toupper(type)) { case 'S': case 'M': case 'F': if (toupper(type) == 'S') { w = width; h = height; } else if(toupper(type) == 'F') { if (image->width * height > image->height * width) { w = (height * image->width) / image->height; h = height; } else { w = width; h = (width * image->height) / image->width; } } else { if (image->width * height > image->height * width) { w = width; h = (width * image->height) / image->width; } else { w = (height * image->width) / image->height; h = height; } } if (w != image->width || h != image->height) { RImage *simage; if (smooth) { simage = RSmoothScaleImage(image, w, h); } else { simage = RScaleImage(image, w, h); } if (!simage) { wwarning("could not scale image:%s", RMessageForError(RErrorCode)); return; } fimage = True; image = simage; } /* fall through */ case 'C': { Pixmap pixmap; if (!RConvertImage(rc, image, &pixmap)) { wwarning("could not convert texture:%s", RMessageForError(RErrorCode)); if (fimage) RReleaseImage(image); return; } if (image->width != width || image->height != height) { int sx, sy, w, h; if (image->height < height) { h = image->height; y += (height - h) / 2; sy = 0; } else { sy = (image->height - height) / 2; h = height; } if (image->width < width) { w = image->width; x += (width - w) / 2; sx = 0; } else { sx = (image->width - width) / 2; w = width; } XCopyArea(dpy, pixmap, texture->pixmap, DefaultGC(dpy, scr), sx, sy, w, h, x, y); } else XCopyArea(dpy, pixmap, texture->pixmap, DefaultGC(dpy, scr), 0, 0, width, height, x, y); XFreePixmap(dpy, pixmap); if (fimage) { RReleaseImage(image); } } break; } }