int main(int argc, char **argv) { RContextAttributes attr; float a; dpy = XOpenDisplay(""); if (!dpy) { puts("cant open display"); exit(1); } attr.flags = RC_RenderMode | RC_ColorsPerChannel; attr.render_mode = RDitheredRendering; attr.colors_per_channel = 4; ctx = RCreateContext(dpy, DefaultScreen(dpy), &attr); if (argc < 2) img = RGetImageFromXPMData(ctx, image_name); else img = RLoadImage(ctx, argv[1], 0); if (!img) { puts(RMessageForError(RErrorCode)); exit(1); } win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, MAX(img->width, img->height), MAX(img->height, img->width), 0, 0, 0); XMapRaised(dpy, win); XFlush(dpy); a = 0; while (1) { RImage *tmp; a = a + 1.0; tmp = RRotateImage(img, a); if (!RConvertImage(ctx, tmp, &pix)) { puts(RMessageForError(RErrorCode)); exit(1); } RReleaseImage(tmp); XSetWindowBackgroundPixmap(dpy, win, pix); XFreePixmap(dpy, pix); XClearWindow(dpy, win); XSync(dpy, 0); usleep(50000); } exit(0); }
WMPixmap *WMCreatePixmapFromFile(WMScreen * scrPtr, const char *fileName) { WMPixmap *pixPtr; RImage *image; image = RLoadImage(scrPtr->rcontext, fileName, 0); if (!image) return NULL; pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127); RReleaseImage(image); return pixPtr; }
static RImage * get_texture_image(WScreen *scr, const char *pixmap_file) { char *file; RImage *image; file = FindImage(wPreferences.pixmap_path, pixmap_file); if (!file) { wwarning(_("image file \"%s\" used as texture could not be found."), pixmap_file); return NULL; } image = RLoadImage(scr->rcontext, file, 0); if (!image) { wwarning(_("could not load texture pixmap \"%s\":%s"), file, RMessageForError(RErrorCode)); wfree(file); return NULL; } wfree(file); return image; }
static RImage *loadImage(RContext * rc, const char *file) { char *path; RImage *image; if (access(file, F_OK) != 0) { path = wfindfile(PixmapPath, file); if (!path) { wwarning("%s:could not find image file used in texture", file); return NULL; } } else { path = wstrdup(file); } image = RLoadImage(rc, path, 0); if (!image) { wwarning("%s:could not load image file used in texture:%s", path, RMessageForError(RErrorCode)); } wfree(path); return image; }
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); WMPixmap *icon1, *icon2; RImage *xis = NULL; RContext *rc = WMScreenRContext(scr); char *path; int i, j, k; char *buf1, *buf2; 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); /***************** Auto-delays *****************/ buf1 = wmalloc(strlen(DELAY_ICON) + 1); buf2 = wmalloc(strlen(DELAY_ICON_S) + 1); for (k = 0; k < 2; k++) { panel->autoDelayF[k] = WMCreateFrame(panel->box); WMResizeWidget(panel->autoDelayF[k], 365, 100); WMMoveWidget(panel->autoDelayF[k], 15, 10 + k * 110); if (k == 0) WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autocollapsing clips")); else WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autoraising clips")); for (i = 0; i < 2; i++) { panel->autoDelayL[i + k * 2] = WMCreateLabel(panel->autoDelayF[k]); WMResizeWidget(panel->autoDelayL[i + k * 2], 165, 20); WMMoveWidget(panel->autoDelayL[i + k * 2], 10, 27 + 40 * i); WMSetLabelText(panel->autoDelayL[i + k * 2], _(auto_delay[i + k * 2].string)); WMSetLabelTextAlignment(panel->autoDelayL[i + k * 2], WARight); for (j = 0; j < 5; j++) { panel->autoDelayB[i + k * 2][j] = WMCreateCustomButton(panel->autoDelayF[k], WBBStateChangeMask); WMResizeWidget(panel->autoDelayB[i + k * 2][j], 25, 25); WMMoveWidget(panel->autoDelayB[i + k * 2][j], 175 + (25 * j), 25 + 40 * i); WMSetButtonBordered(panel->autoDelayB[i + k * 2][j], False); WMSetButtonImagePosition(panel->autoDelayB[i + k * 2][j], WIPImageOnly); WMSetButtonAction(panel->autoDelayB[i + k * 2][j], pushAutoDelayButton, panel); if (j > 0) WMGroupButtons(panel->autoDelayB[i + k * 2][0], panel->autoDelayB[i + k * 2][j]); sprintf(buf1, DELAY_ICON, j); CreateImages(scr, rc, NULL, buf1, &icon1, NULL); if (icon1) { WMSetButtonImage(panel->autoDelayB[i + k * 2][j], icon1); WMReleasePixmap(icon1); } else { wwarning(_("could not load icon file %s"), buf1); } sprintf(buf2, DELAY_ICON_S, j); CreateImages(scr, rc, NULL, buf2, &icon2, NULL); if (icon2) { WMSetButtonAltImage(panel->autoDelayB[i + k * 2][j], icon2); WMReleasePixmap(icon2); } else { wwarning(_("could not load icon file %s"), buf2); } } panel->autoDelayT[i + k * 2] = WMCreateTextField(panel->autoDelayF[k]); WMResizeWidget(panel->autoDelayT[i + k * 2], 36, 20); WMMoveWidget(panel->autoDelayT[i + k * 2], 310, 27 + 40 * i); WMAddNotificationObserver(autoDelayChanged, panel, WMTextDidChangeNotification, panel->autoDelayT[i + k * 2]); } WMMapSubwidgets(panel->autoDelayF[k]); } wfree(buf1); wfree(buf2); /***************** Enable/disable clip/dock/drawers *****************/ panel->dockF = WMCreateFrame(panel->box); WMResizeWidget(panel->dockF, 115, 210); WMMoveWidget(panel->dockF, 390, 10); WMSetFrameTitle(panel->dockF, _("Dock/Clip/Drawer")); for (i = 0; i < 3; i++) { panel->docksB[i] = WMCreateButton(panel->dockF, WBTToggle); WMResizeWidget(panel->docksB[i], 56, 56); WMMoveWidget(panel->docksB[i], 30, 20 + 62 * i); WMSetButtonImagePosition(panel->docksB[i], WIPImageOnly); CreateImages(scr, rc, xis, dock_config[i].icon_file, &icon1, &icon2); if (icon2) { WMSetButtonImage(panel->docksB[i], icon2); WMReleasePixmap(icon2); } if (icon1) { WMSetButtonAltImage(panel->docksB[i], icon1); WMReleasePixmap(icon1); } switch(i) { case 0: WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n" "vertical icon bar in the side of the screen)."), WMWidgetView(panel->docksB[i])); break; case 1: WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n" "a paper clip icon)."), WMWidgetView(panel->docksB[i])); break; case 2: WMSetBalloonTextForView(_("Disable/enable Drawers (a dock that stores\n" "application icons horizontally). The dock is required."), WMWidgetView(panel->docksB[i])); break; } WMSetButtonAction(panel->docksB[i], pushDockButton, panel); } WMMapSubwidgets(panel->dockF); if (xis) RReleaseImage(xis); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
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); }
static Bool loadPixmaps(WMScreen * scr) { RImage *image, *tmp; RColor gray; RColor white; gray.red = 0xae; gray.green = 0xaa; gray.blue = 0xae; white.red = 0xff; white.green = 0xff; white.blue = 0xff; image = RLoadImage(scr->rcontext, T_WINGS_IMAGES_FILE, 0); if (!image) image = RLoadImage(scr->rcontext, X_WINGS_IMAGES_FILE, 0); if (!image) { wwarning(_("WINGs: could not load widget images file: %s"), RMessageForError(RErrorCode)); return False; } /* home icon */ /* make it have a gray background */ tmp = RGetSubImage(image, 0, 0, 24, 24); RCombineImageWithColor(tmp, &gray); scr->homeIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* make it have a white background */ tmp = RGetSubImage(image, 0, 0, 24, 24); RCombineImageWithColor(tmp, &white); scr->altHomeIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* trash can */ tmp = RGetSubImage(image, 104, 0, 24, 24); RCombineImageWithColor(tmp, &white); scr->trashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 104, 0, 24, 24); RCombineImageWithColor(tmp, &white); scr->altTrashcanIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* create dir */ tmp = RGetSubImage(image, 104, 24, 24, 24); RCombineImageWithColor(tmp, &white); scr->createDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 104, 24, 24, 24); RCombineImageWithColor(tmp, &white); scr->altCreateDirIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* diskettes */ tmp = RGetSubImage(image, 24, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->disketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 24, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->altDisketteIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* unmount */ tmp = RGetSubImage(image, 0, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->unmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); tmp = RGetSubImage(image, 0, 80, 24, 24); RCombineImageWithColor(tmp, &white); scr->altUnmountIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* Magnifying Glass Icon for ColorPanel */ tmp = RGetSubImage(image, 24, 0, 40, 32); RCombineImageWithColor(tmp, &gray); scr->magnifyIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* ColorWheel Icon for ColorPanel */ tmp = RGetSubImage(image, 0, 25, 24, 24); scr->wheelIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* GrayScale Icon for ColorPanel */ tmp = RGetSubImage(image, 65, 0, 40, 24); scr->grayIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* RGB Icon for ColorPanel */ tmp = RGetSubImage(image, 25, 33, 40, 24); scr->rgbIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* CMYK Icon for ColorPanel */ tmp = RGetSubImage(image, 65, 25, 40, 24); scr->cmykIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* HSB Icon for ColorPanel */ tmp = RGetSubImage(image, 0, 57, 40, 24); scr->hsbIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* CustomColorPalette Icon for ColorPanel */ tmp = RGetSubImage(image, 81, 57, 40, 24); scr->customPaletteIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); /* ColorList Icon for ColorPanel */ tmp = RGetSubImage(image, 41, 57, 40, 24); scr->colorListIcon = WMCreatePixmapFromRImage(scr, tmp, 128); RReleaseImage(tmp); RReleaseImage(image); return True; }