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; }
WMPixmap *WMCreatePixmapFromXPMData(WMScreen * scrPtr, char **data) { WMPixmap *pixPtr; RImage *image; image = RGetImageFromXPMData(scrPtr->rcontext, data); if (!image) return NULL; pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127); RReleaseImage(image); return pixPtr; }
WMPixmap *WMCreateBlendedPixmapFromRImage(WMScreen * scrPtr, RImage * image, const RColor * color) { WMPixmap *pixPtr; RImage *copy; copy = RCloneImage(image); if (!copy) return NULL; RCombineImageWithColor(copy, color); pixPtr = WMCreatePixmapFromRImage(scrPtr, copy, 0); RReleaseImage(copy); return pixPtr; }
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; }
int main (int argc, char **argv){ int i,j; WMColor *color; WMWindow * win; RImage *image; struct _pict pict; Drawable de; RColor one, two={0xaf, 0x0f,0xff,0x33}; one.red=247; one.green=251; one.blue=107; one.alpha=0xff; WMInitializeApplication("DrawWin", &argc, argv); display = XOpenDisplay(""); screen = WMCreateScreen(display, DefaultScreen(display)); win = WMCreateWindow(screen, ""); WMResizeWidget(win, WINWIDTH, WINHEIGHT); WMSetWindowCloseAction(win, closeAction, NULL); WMSetWindowTitle(win,"Graphics"); color = WMCreateRGBColor(screen,124<<9,206<<8,162<<8, False); WMSetWidgetBackgroundColor((WMWidget *)win, color); /* end setup main window */ image=RCreateImage( 100,100,0.5); RFillImage(image, &two); RDrawLine(image, 50,10,90,90,&one); RDrawLine(image, 10,90,50,10,&one); RDrawLine(image, 10,90,90,90,&one); g3=WMColorGC(screen->gray); XSetLineAttributes(display,g3,3,LineSolid,CapButt,JoinMiter); pict.segments[1].x1= pict.segments[0].x1=HOFF; pict.segments[0].x2=HOFF; pict.segments[0].y1=VOFF; pict.segments[1].y2= pict.segments[0].y2=VOFF; pict.segments[1].x2= HOFF+10; pict.segments[1].y1=VOFF+10; pict.seglen=2; for (i=9;i>0;i--){ j=2*(10-i); pict.segments[j+1].x1= pict.segments[j].x1=HOFF; pict.segments[j+1].y2= pict.segments[j].y2=VOFF; pict.segments[j].x2= i+pict.segments[j-1].x2; pict.segments[j].y1=i+pict.segments[j-1].y1; pict.segments[j+1].x2= i+pict.segments[j].x2; pict.segments[j+1].y1=i+pict.segments[j].y1; pict.seglen+=2; }; WMRealizeWidget(win); pict.dwin=W_VIEW_DRAWABLE(WMWidgetView(win)); pixmap=WMCreatePixmapFromRImage(screen, image,1); WMCreateEventHandler(WMWidgetView(win), ExposureMask,drawProcedure,&pict); WMMapWidget(win); WMScreenMainLoop(screen); }
void testGradientButtons(WMScreen * scr) { WMWindow *win; WMButton *btn; WMPixmap *pix1, *pix2; RImage *back; RColor light, dark; WMColor *color, *altColor; windowCount++; /* creates the top-level window */ win = WMCreateWindow(scr, "testGradientButtons"); WMSetWindowTitle(win, "Gradiented Button Demo"); WMResizeWidget(win, 300, 200); WMSetWindowCloseAction(win, closeAction, NULL); light.red = 0x90; light.green = 0x85; light.blue = 0x90; dark.red = 0x35; dark.green = 0x30; dark.blue = 0x35; color = WMCreateRGBColor(scr, 0x5900, 0x5100, 0x5900, True); WMSetWidgetBackgroundColor(win, color); WMReleaseColor(color); back = RRenderGradient(60, 24, &dark, &light, RGRD_DIAGONAL); RBevelImage(back, RBEV_RAISED2); pix1 = WMCreatePixmapFromRImage(scr, back, 0); RReleaseImage(back); back = RRenderGradient(60, 24, &dark, &light, RGRD_DIAGONAL); RBevelImage(back, RBEV_SUNKEN); pix2 = WMCreatePixmapFromRImage(scr, back, 0); RReleaseImage(back); color = WMWhiteColor(scr); altColor = WMCreateNamedColor(scr, "red", True); btn = WMCreateButton(win, WBTMomentaryChange); WMResizeWidget(btn, 60, 24); WMMoveWidget(btn, 20, 100); WMSetButtonBordered(btn, False); WMSetButtonImagePosition(btn, WIPOverlaps); WMSetButtonImage(btn, pix1); WMSetButtonAltImage(btn, pix2); WMSetButtonText(btn, "Cool"); WMSetButtonTextColor(btn, color); WMSetButtonAltTextColor(btn, altColor); WMSetBalloonTextForView("This is a cool button", WMWidgetView(btn)); btn = WMCreateButton(win, WBTMomentaryChange); WMResizeWidget(btn, 60, 24); WMMoveWidget(btn, 90, 100); WMSetButtonBordered(btn, False); WMSetButtonImagePosition(btn, WIPOverlaps); WMSetButtonImage(btn, pix1); WMSetButtonAltImage(btn, pix2); WMSetButtonText(btn, "Button"); WMSetButtonTextColor(btn, color); WMSetBalloonTextForView("Este é outro balão.", WMWidgetView(btn)); WMReleaseColor(color); color = WMCreateNamedColor(scr, "orange", True); btn = WMCreateButton(win, WBTMomentaryChange); WMResizeWidget(btn, 60, 24); WMMoveWidget(btn, 160, 100); WMSetButtonBordered(btn, False); WMSetButtonImagePosition(btn, WIPOverlaps); WMSetButtonImage(btn, pix1); WMSetButtonAltImage(btn, pix2); WMSetButtonText(btn, "Test"); WMSetButtonTextColor(btn, color); WMSetBalloonTextForView("This is yet another button.\nBut the balloon has 3 lines.\nYay!", WMWidgetView(btn)); WMReleaseColor(color); WMReleaseColor(altColor); WMRealizeWidget(win); WMMapSubwidgets(win); WMMapWidget(win); }
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; }