void paintBackground( XInfo& xinfo, PixmapArray& pixmapArray ) { XClearWindow( xinfo.display, xinfo.window ); // Paint rainbow paintRainbowArc( xinfo, 0, XInfoColor::ORANGE ); paintRainbowArc( xinfo, 1, XInfoColor::YELLOW ); paintRainbowArc( xinfo, 2, XInfoColor::GREEN ); paintRainbowArc( xinfo, 3, XInfoColor::BLUE ); paintRainbowArc( xinfo, 4, XInfoColor::INDIGO ); paintRainbowArc( xinfo, 5, XInfoColor::PURPLE ); paintRainbowArc( xinfo, 6, XInfoColor::RED ); // Paint title int titleX = xinfo.windowAttr.width/2 - (290/2); int titleY = 50; XSetForeground( xinfo.display, xinfo.gc, xinfo.color[ (int) XInfoColor::BLACK ].pixel ); XSetBackground( xinfo.display, xinfo.gc, xinfo.color[ (int) XInfoColor::RED ].pixel ); XCopyPlane( xinfo.display, pixmapArray[ PixmapArray::TITLE ], xinfo.window, xinfo.gc, 0, 0, 290, 184, titleX, titleY, 1 ); // Paint Stalin and instructions int stalinX = xinfo.windowAttr.width - 469; int stalinY = xinfo.windowAttr.height - 307; XCopyPlane( xinfo.display, pixmapArray[ PixmapArray::STALIN ], xinfo.window, xinfo.gc, 0, 0, 469, 307, stalinX, stalinY, 1 ); }
static void update_display (p_state *state, Bool changed_only) { int x, y; for (y = 0; y < state->grid_height; y++) for (x = 0; x < state->grid_width; x++) { p_cell *cell = &state->cells[state->grid_width * y + x]; int width, height, tx, ty; if (changed_only && !cell->changed) continue; width = state->char_width * state->scale; height = state->char_height * state->scale; tx = x * width; ty = y * height; if (cell->state == BLANK || cell->p_char->blank_p) { XFillRectangle (state->dpy, state->window, state->gcs[BLANK], tx, ty, width, height); } else { #ifdef FUZZY_BORDER GC gc1 = state->gcs[cell->state]; GC gc2 = ((cell->state + 2) < state->ticks ? state->gcs[cell->state + 2] : 0); GC gc3 = (gc2 ? gc2 : gc1); if (gc3) XCopyPlane (state->dpy, cell->p_char->pixmap, state->window, gc3, 0, 0, width, height, tx, ty, 1L); if (gc2) { XSetClipMask (state->dpy, gc1, cell->p_char->pixmap2); XSetClipOrigin (state->dpy, gc1, tx, ty); XFillRectangle (state->dpy, state->window, gc1, tx, ty, width, height); XSetClipMask (state->dpy, gc1, None); } #else /* !FUZZY_BORDER */ XCopyPlane (state->dpy, cell->p_char->pixmap, state->window, state->gcs[cell->state], 0, 0, width, height, tx, ty, 1L); #endif /* !FUZZY_BORDER */ } cell->changed = False; } }
static void rock_draw(Window win, arock *arocks, int draw_p) { rockstruct *rp = &rocks[screen]; if (draw_p) XSetForeground(dsp, Scr[screen].gc, arocks->color); else XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen)); if (arocks->x <= 0 || arocks->y <= 0 || arocks->x >= rp->width || arocks->y >= rp->height) { /* this means that if a rock were to go off the screen at 12:00, but would have been visible at 3:00, it won't come back once the observer rotates around so that the rock would have been visible again. Oh well. */ if (!rp->move_p) arocks->depth = 0; return; } if (arocks->size <= 1) XDrawPoint (dsp, win, Scr[screen].gc, arocks->x, arocks->y); else if (arocks->size <= 3 || !draw_p) XFillRectangle(dsp, win, Scr[screen].gc, arocks->x - arocks->size/2, arocks->y - arocks->size/2, arocks->size, arocks->size); else if (arocks->size < MAX_WIDTH) XCopyPlane(dsp, rp->pixmaps[arocks->size], win, Scr[screen].gc, 0, 0, arocks->size, arocks->size, arocks->x - arocks->size/2, arocks->y - arocks->size/2, 1L); }
void copyplane_test(void) { int num_copies = 200; int i; long totaltime; char buf[80]; if(!X.gcv.plane_mask || (X.gcv.plane_mask & (X.gcv.plane_mask - 1))) { show_result("exactly one bit in plane mask must be set for this test"); return; } num_copies *= X.percent; XSetPlaneMask(X.dpy, X.gc, ~0L); XSetFillStyle(X.dpy,X.miscgc,FillTiled); XFillRectangle(X.dpy,X.win,X.miscgc,0,0,400,400); XSync(X.dpy,0); timer(StartTimer); for (i=0;i<num_copies;++i) XCopyPlane(X.dpy,X.win,X.win,X.gc,i,200-i, 200,200,200-i,i,X.gcv.plane_mask); XSync(X.dpy,0); totaltime = timer(EndTimer); XSetPlaneMask(X.dpy, X.gc, X.gcv.plane_mask); snprintf(buf,sizeof buf,"%.2f seconds.",(double)totaltime/1000000.); show_result(buf); }
/* Copy shape-mask and pixmap-data from an area in one shaped pixmap * into another shaped pixmap */ void DASPCopyArea(DAShapedPixmap *src, DAShapedPixmap *dst, int x1, int y1, int w, int h, int x2, int y2) { assert(src != NULL && dst != NULL); XCopyPlane(DADisplay, src->shape, dst->shape, src->shapeGC, x1, y1, w, h, x2, y2, 1); XCopyArea(DADisplay, src->pixmap, dst->pixmap, src->drawGC, x1, y1, w, h, x2, y2); }
static void mf_redraw () { XCopyPlane (mf_display, mf_pixmap, mf_window, mf_cgc, 0, 0, mf_x11_resources.mf_width, mf_x11_resources.mf_height, 0, 0, (unsigned long) 1); XFlush (mf_display); }
void DoCopyPlane(XParms xp, Parms p, int reps) { int i, size; XSegment *sa, *sb; size = p->special; for (sa = segsa, sb = segsb, i = 0; i != reps; i++, sa++, sb++) { XCopyPlane(xp->d, pix, xp->w, xp->fggc, sa->x1, sa->y1, size, size, sa->x2, sa->y2, 1); XCopyPlane(xp->d, pix, xp->w, xp->fggc, sa->x2, sa->y2, size, size, sa->x1, sa->y1, 1); XCopyPlane(xp->d, pix, xp->w, xp->fggc, sb->x2, sb->y2, size, size, sb->x1, sb->y1, 1); XCopyPlane(xp->d, pix, xp->w, xp->fggc, sb->x1, sb->y1, size, size, sb->x2, sb->y2, 1); CheckAbort (); } }
static void xf_floatbar_button_event_expose(xfFloatbar* floatbar, XEvent* event) { xfFloatbarButton* button = xf_floatbar_get_button(floatbar, event); static unsigned char* bits; GC gc; Pixmap pattern; xfContext* xfc = floatbar->xfc; if (!button) return; gc = XCreateGC(xfc->display, button->handle, 0, 0); floatbar = xfc->window->floatbar; switch (button->type) { case XF_FLOATBAR_BUTTON_CLOSE: bits = close_bits; break; case XF_FLOATBAR_BUTTON_RESTORE: bits = restore_bits; break; case XF_FLOATBAR_BUTTON_MINIMIZE: bits = minimize_bits; break; case XF_FLOATBAR_BUTTON_LOCKED: if (floatbar->locked) bits = lock_bits; else bits = unlock_bits; break; default: break; } pattern = XCreateBitmapFromData(xfc->display, button->handle, (const char*)bits, FLOATBAR_BUTTON_WIDTH, FLOATBAR_BUTTON_WIDTH); if (!(button->focus)) XSetForeground(xfc->display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BACKGROUND)); else XSetForeground(xfc->display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_BORDER)); XSetBackground(xfc->display, gc, xf_floatbar_get_color(floatbar, FLOATBAR_COLOR_FOREGROUND)); XCopyPlane(xfc->display, pattern, button->handle, gc, 0, 0, FLOATBAR_BUTTON_WIDTH, FLOATBAR_BUTTON_WIDTH, 0, 0, 1); XFreePixmap(xfc->display, pattern); XFreeGC(xfc->display, gc); }
void DisplayRatBitmap(int screenX, int screenY, int width, int height, int srcX, int srcY) { #ifdef USE_BITMAPS XCopyPlane(dpy, ratsBitmap, mwWindow, xorGC, srcX, srcY, width, height, screenX + VIEW_X_ORIGIN, screenY + VIEW_Y_ORIGIN, 1); #else XPutImage(dpy, mwWindow, xorGC, ratsImage, srcX, srcY, screenX+VIEW_X_ORIGIN, screenY+VIEW_Y_ORIGIN, width, height); #endif /* USE_BITMAPS */ }
/*ARGSUSED*/ static void draw_pixmap(XmEnhancedButtonWidget eb, XEvent *event, Region region) { Pixmap pix; GC gc = eb->label.normal_GC; int depth; Cardinal width; Cardinal height; Cardinal w; Cardinal h; int x; int y; if (!XtIsSensitive((Widget) eb)) pix = eb->enhancedbutton.insensitive_pixmap; else { if (eb->primitive.highlighted && !eb->pushbutton.armed) pix = eb->enhancedbutton.highlight_pixmap; else if (eb->pushbutton.armed) pix = eb->enhancedbutton.armed_pixmap; else pix = eb->enhancedbutton.normal_pixmap; } if (pix == None || !eb->enhancedbutton.pixmap_data) return; depth = eb->enhancedbutton.pixmap_depth; w = eb->enhancedbutton.pixmap_width; h = eb->enhancedbutton.pixmap_height; gc = eb->label.normal_GC; x = eb->primitive.highlight_thickness + eb->primitive.shadow_thickness + eb->label.margin_width; y = eb->primitive.highlight_thickness + eb->primitive.shadow_thickness + eb->label.margin_height; width = eb->core.width - 2 * x; if (w < width) width = w; height = eb->core.height - 2 * y; if (h < height) height = h; if (depth == eb->core.depth) XCopyArea(XtDisplay(eb), pix, XtWindow(eb), gc, 0, 0, width, height, x, y); else if (depth == 1) XCopyPlane(XtDisplay(eb), pix, XtWindow(eb), gc, 0, 0, width, height, x, y, (unsigned long)1); }
/* * actually put the maze Pixmap on the screen. */ void drawMaze() { #ifdef USE_BITMAPS XCopyPlane(dpy, mazeBitmap, mwWindow, copyGC, 0, 0, MAZE_X_DIM, MAZE_Y_DIM, MAZE_X_ORIGIN, MAZE_Y_ORIGIN, 1); #else XPutImage(dpy, mwWindow, copyGC, mazeImage, 0, 0, MAZE_X_ORIGIN, MAZE_Y_ORIGIN, MAZE_X_DIM, MAZE_Y_DIM); #endif /* USE_BITMAPS */ }
void MSPixmap::create(MSDisplayServer *pServer_,const char *pName_, const char *bitmapFile_,unsigned long fg_,unsigned long bg_) { Display *display=pServer_->display(); Window window=pServer_->root(); int depth=DefaultDepthOfScreen(pServer_->screen()); unsigned w,h; Pixmap bitmap; #ifdef MS_WINDOWS int res; if (bitmapFile_==0) res=MSXReadBitmapFromResource(display,window,_name,&w,&h,&bitmap); else res=MSXReadBitmapFromXbmFile(display,window,bitmapFile_,&w,&h,&bitmap,fg_,bg_,depth); if( res==BitmapSuccess) { _pData=new MSPixmapData(pServer_,pName_,bitmap,w,h,depth,fg_,bg_); #else if (XReadBitmapFile(display,window,bitmapFile_,&w,&h,&bitmap,0,0)==BitmapSuccess) { Pixmap pixmap=XCreatePixmap(display,window,w,h,depth); GC gc=XCreateGC(display,window,0,0); XSetForeground(display,gc,fg_); XSetBackground(display,gc,bg_); XCopyPlane(display,bitmap,pixmap,gc,0,0,w,h,0,0,1); XFreeGC(display,gc); XFreePixmap(display,bitmap); _pData=new MSPixmapData(pServer_,pName_,pixmap,w,h,depth,fg_,bg_); #endif addToHashTable(pName_,(void *)_pData); addReference(); } else { // Can't read bitmap file, create one with background color MSMessageLog::warningMessage("MSPixmap warning: Unable to create Pixmap from file %s\n",bitmapFile_); char buf[255]; sprintf(buf,"Predefined_%s_%d_%d_%d_%d",MSPixmap::SolidBackgroundPixmap,fg_,bg_,depth,display); if(copyPixmapDataWithKey(buf)==MSFalse) create(pServer_,MSPixmap::SolidBackgroundPixmap,fg_,bg_); } } void MSPixmap::create(MSDisplayServer *pServer_,const char *pName_, int w_,int h_,unsigned long fg_,unsigned long bg_) { int dep=DefaultDepthOfScreen(pServer_->screen()); Pixmap p=XCreatePixmap(pServer_->display(),pServer_->root(),w_,h_,dep); create(pServer_,pName_,p,w_,h_,dep,fg_,bg_); }
Bool GetBackPixmap(void) { Pixmap maskPixmap; char *path = NULL; Pixmap tmp_pixmap; int w=0, h=0; int icon_depth = 0; FvwmPictureAttributes fpa; fpa.mask = FPAM_NO_ALLOC_PIXELS | FPAM_NO_ALPHA; if (Pdepth <= 8) { fpa.mask |= FPAM_DITHER; } if (IconwinPixmapFile == NULL) return False; path = PictureFindImageFile(IconwinPixmapFile, imagePath, R_OK); if (path == NULL) { return False; } if (!PImageLoadPixmapFromFile( dpy, main_win, path, &tmp_pixmap, &maskPixmap, NULL, &w, &h, &icon_depth, 0, NULL, 0, fpa)) { w = 0; h = 0; fprintf(stderr, "[FvwmIconBox] Problem creating pixmap from " "file: %s\n", path); free(path); return False; } if (icon_depth == 1) { IconwinPixmap = XCreatePixmap(dpy, main_win, w, h, Pdepth); XCopyPlane(dpy, tmp_pixmap, IconwinPixmap, NormalGC, 0, 0, w, h, 0, 0, 1); XFreePixmap(dpy, tmp_pixmap); } else { IconwinPixmap = tmp_pixmap; } free(path); if (w != 0 && h != 0) return True; return False; }
static void reset_cs_pixmap(colorset_t *cs, GC gc) { if (Pdepth == cs->picture->depth) { XCopyArea(dpy, cs->picture->picture, cs->pixmap, gc, 0, 0, cs->width, cs->height, 0, 0); } else { XCopyPlane(dpy, cs->picture->picture, cs->pixmap, gc, 0, 0, cs->width, cs->height, 0, 0, 1); } return; }
static void draw_passwd_window (saver_info *si) { passwd_dialog_data *pw = si->pw_data; XGCValues gcv; GC gc1, gc2; /* Force redraw */ pw->passwd_changed_p = True; gcv.foreground = pw->foreground; gc1 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv); gc2 = XCreateGC (si->dpy, si->passwd_dialog, GCForeground, &gcv); if (pw->logo_pixmap) { Window root; int x, y; unsigned int w, h, bw, d; XGetGeometry (si->dpy, pw->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d); XSetForeground (si->dpy, gc1, pw->foreground); XSetBackground (si->dpy, gc1, pw->background); XSetClipMask (si->dpy, gc1, pw->logo_clipmask); /* [email protected] - Let's auto center / crop this background image */ if (w > pw->width) { x = MAX((w - pw->width) / 2, 0); w = pw->width; } if (h > pw->height) { y = MAX((h - pw->height)/ 2, 0); h = pw->height; } XSetClipOrigin (si->dpy, gc1, pw->x, pw->y); if (d == 1) XCopyPlane (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1, x, y, w, h, pw->x, pw->y, 1); else XCopyArea (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1, x, y, w, h, pw->x, pw->y); } XFreeGC (si->dpy, gc1); XFreeGC (si->dpy, gc2); update_passwd_window (si, pw->passwd_string, pw->ratio); }
void scale_icon (task *tk) { int xx, yy, x, y, w, h, d, bw; Pixmap pix, mk = None; XGCValues gcv; GC mgc; XGetGeometry (dd, tk->icon, &pix, &x, &y, &w, &h, &bw, &d); pix = XCreatePixmap (dd, tk->win, ICONWIDTH, ICONHEIGHT, scr_depth); if (tk->mask != None) { mk = XCreatePixmap (dd, tk->win, ICONWIDTH, ICONHEIGHT, 1); gcv.subwindow_mode = IncludeInferiors; gcv.graphics_exposures = False; mgc = XCreateGC (dd, mk, GCGraphicsExposures | GCSubwindowMode, &gcv); } set_foreground (5); /* this is my simple & dirty scaling routine */ for (y = ICONHEIGHT - 1; y >= 0; y--) { yy = (y * h) / ICONHEIGHT; for (x = ICONWIDTH - 1; x >= 0; x--) { xx = (x * w) / ICONWIDTH; if (d != scr_depth) XCopyPlane (dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y, 1); else XCopyArea (dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y); if (mk != None) XCopyArea (dd, tk->mask, mk, mgc, xx, yy, 1, 1, x, y); } } if (mk != None) { XFreeGC (dd, mgc); tk->mask = mk; } tk->icon = pix; }
/* Render a single word object to the screen. */ static void draw_word (state *s, sentence *se, word *w) { if (! w->pixmap) return; if (w->x + w->width < 0 || w->y + w->height < 0 || w->x > s->xgwa.width || w->y > s->xgwa.height) return; XSetClipMask (s->dpy, se->fg_gc, w->mask); XSetClipOrigin (s->dpy, se->fg_gc, w->x, w->y); XCopyPlane (s->dpy, w->pixmap, s->b, se->fg_gc, 0, 0, w->width, w->height, w->x, w->y, 1L); }
static PyObject * pixmap_CopyPlane(PaxPixmapObject *self, PyObject *args) { PyObject *destobj, *gcobj; Tk_Window w = NULL; Drawable dest; GC gc; int src_x, src_y, dest_x, dest_y; unsigned int width, height; unsigned long plane; if (!PyArg_ParseTuple(args, "OOiiiiiii", &destobj, &gcobj, &src_x, &src_y, &width, &height, &dest_x, &dest_y, &plane)) return NULL; if (TkWin_Check(destobj)) { w = TkWin_AsTkWindow(destobj); dest = Tk_WindowId(w); } else if (PaxPixmap_Check(destobj)) { dest = PaxPixmap_AsPixmap(destobj); } else { PyErr_SetString(PyExc_RuntimeError, "bad arguments"); return NULL; } if (gcobj == Py_None && w) gc = DefaultGCOfScreen(Tk_Screen(w)); else { gc = PaxGC_AsGC(gcobj); if (PyErr_Occurred()) return NULL; } XCopyPlane(self->display, self->pixmap, dest, gc, src_x, src_y, width, height, dest_x, dest_y, plane); Py_INCREF(Py_None); return Py_None; }
static void ImgBmapDisplay( ClientData clientData, /* Pointer to BitmapInstance structure for * instance to be displayed. */ Display *display, /* Display on which to draw image. */ Drawable drawable, /* Pixmap or window in which to draw image. */ int imageX, int imageY, /* Upper-left corner of region within image to * draw. */ int width, int height, /* Dimensions of region within image to draw. */ int drawableX, int drawableY) /* Coordinates within drawable that correspond * to imageX and imageY. */ { BitmapInstance *instancePtr = clientData; int masking; /* * If there's no graphics context, it means that an error occurred while * creating the image instance so it can't be displayed. */ if (instancePtr->gc == None) { return; } /* * If masking is in effect, must modify the mask origin within the * graphics context to line up with the image's origin. Then draw the * image and reset the clip origin, if there's a mask. */ masking = (instancePtr->mask != None) || (instancePtr->bg == NULL); if (masking) { XSetClipOrigin(display, instancePtr->gc, drawableX - imageX, drawableY - imageY); } XCopyPlane(display, instancePtr->bitmap, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY, 1); if (masking) { XSetClipOrigin(display, instancePtr->gc, 0, 0); } }
Pixmap char_to_pixmap(Widget w, int font, char c, int csize) { X11Stuff *xstuff = gapp->gui->xstuff; CPixmap *pm; Pixmap pixmap = 0; int height, width, hshift, vshift; float fsize = 0.8*(float)csize; Canvas *canvas = grace_get_canvas(gapp->grace); pm = canvas_raster_char(canvas, grace_fmap(gapp->gp, canvas, font), c, fsize, &vshift, &hshift); if (pm != NULL && pm->bits != NULL) { long bg, fg; Pixmap ptmp; vshift = csize - vshift - 4; height = pm->height; width = pm->width; ptmp = XCreateBitmapFromData(xstuff->disp, xstuff->root, pm->bits, width, height); pixmap = XCreatePixmap(xstuff->disp, xstuff->root, csize, csize, xstuff->depth); XtVaGetValues(w, XmNbackground, &bg, XmNforeground, &fg, NULL); XSetFillStyle(xstuff->disp, xstuff->gc, FillSolid); XSetForeground(xstuff->disp, xstuff->gc, bg); XFillRectangle(xstuff->disp, pixmap, xstuff->gc, 0, 0, csize, csize); XSetBackground(xstuff->disp, xstuff->gc, bg); XSetForeground(xstuff->disp, xstuff->gc, fg); XCopyPlane(xstuff->disp, ptmp, pixmap, xstuff->gc, 0, 0, width, height, hshift, vshift, 1); XFreePixmap(xstuff->disp, ptmp); } canvas_cpixmap_free(pm); return pixmap; }
/*********************************************************************** * BRUSH_SelectPatternBrush */ static BOOL BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap ) { BITMAP bitmap; X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap ); if (!physBitmap || !GetObjectW( hbitmap, sizeof(bitmap), &bitmap )) return FALSE; X11DRV_DIB_Lock( physBitmap, DIB_Status_GdiMod ); if ((physDev->depth == 1) && (physBitmap->pixmap_depth != 1)) { wine_tsx11_lock(); /* Special case: a color pattern on a monochrome DC */ physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window, bitmap.bmWidth, bitmap.bmHeight, 1); /* FIXME: should probably convert to monochrome instead */ XCopyPlane( gdi_display, physBitmap->pixmap, physDev->brush.pixmap, get_bitmap_gc(1), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0, 1 ); wine_tsx11_unlock(); } else { /* XRender is needed because of possible depth conversion */ X11DRV_XRender_CopyBrush(physDev, physBitmap, bitmap.bmWidth, bitmap.bmHeight); } X11DRV_DIB_Unlock( physBitmap, TRUE ); if (physBitmap->pixmap_depth > 1) { physDev->brush.fillStyle = FillTiled; physDev->brush.pixel = 0; /* Ignored */ } else { physDev->brush.fillStyle = FillOpaqueStippled; physDev->brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */ } return TRUE; }
Pixmap XbrGfxReadBitmap(Display *display, Screen *screen, GC gc, char *bits, int width, int height) { Pixmap bitmap, pixmap; /* Create a bitmap from the bits passed in */ bitmap = XCreateBitmapFromData(display, RootWindowOfScreen(screen), bits, width, height); /* Create a pixmap with the same dimensions */ pixmap = XCreatePixmap(display, RootWindowOfScreen(screen), width, height, DefaultDepthOfScreen(screen)); /* Copy the bitmap onto the first plane of the pixmap */ XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); /* Finished with the bitmap */ XFreePixmap(display, bitmap); /* Done. */ return(pixmap); }
/** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst * drawable on the back-end server associated with \a pSrc drawable's * screen. If the offscreen optimization is enabled, only copy when * both \a pSrc and \a pDst are at least partially visible. */ RegionPtr dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, unsigned long bitPlane) { DMXScreenInfo *dmxScreen = &dmxScreens[pSrc->pScreen->myNum]; dmxGCPrivPtr pGCPriv = DMX_GET_GC_PRIV(pGC); Drawable srcDraw, dstDraw; if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst)) return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw); DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw); XCopyPlane(dmxScreen->beDisplay, srcDraw, dstDraw, pGCPriv->gc, srcx, srcy, width, height, dstx, dsty, bitPlane); dmxSync(dmxScreen, FALSE); return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height, dstx, dsty, bitPlane); }
/*********************************************************************** * BRUSH_SelectPatternBrush */ static void BRUSH_SelectPatternBrush( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, X_PHYSBITMAP *physBitmap ) { BITMAP bitmap; GetObjectW( hbitmap, sizeof(bitmap), &bitmap ); wine_tsx11_lock(); if (physDev->brush.pixmap) XFreePixmap( gdi_display, physDev->brush.pixmap ); if ((physDev->depth == 1) && (physBitmap->depth != 1)) { /* Special case: a color pattern on a monochrome DC */ physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window, bitmap.bmWidth, bitmap.bmHeight, 1); /* FIXME: should probably convert to monochrome instead */ XCopyPlane( gdi_display, physBitmap->pixmap, physDev->brush.pixmap, get_bitmap_gc(1), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0, 1 ); } else { physDev->brush.pixmap = XCreatePixmap( gdi_display, root_window, bitmap.bmWidth, bitmap.bmHeight, physBitmap->depth ); XCopyArea( gdi_display, physBitmap->pixmap, physDev->brush.pixmap, get_bitmap_gc(physBitmap->depth), 0, 0, bitmap.bmWidth, bitmap.bmHeight, 0, 0 ); } wine_tsx11_unlock(); if (physBitmap->depth > 1) { physDev->brush.fillStyle = FillTiled; physDev->brush.pixel = 0; /* Ignored */ } else { physDev->brush.fillStyle = FillOpaqueStippled; physDev->brush.pixel = -1; /* Special case (see DC_SetupGCForBrush) */ } }
void XImlib2Caption::renderFont2Imlib() { XDesktopContainer * xContainer = dynamic_cast<XDesktopContainer *>(AbstractImage::container); Display * display = xContainer->getDisplay(); int screen = DefaultScreen(display); pixmap = XCreatePixmap(display, window, width, height, DefaultDepth(display, screen)); XSetWindowBackgroundPixmap (display, window, pixmap); gc = XCreateGC(display, window, 0, 0); if( pixmap == (Pixmap) NULL ) { printf("\nError creando Pixmap\n"); XCloseDisplay(display); exit(1); } fontDrawHandle = XftDrawCreate(display, pixmap, visual, cmap); XSetFillStyle(display, gc, FillSolid); XSetForeground(display, gc, BlackPixel(display, 0)); XSetBackground(display, gc, WhitePixel(display, 0)); XFillRectangle(display, pixmap, gc, 0, 0, width, height); Pixmap shapeMask = XCreatePixmap(display, window, width, height,1); GC tempGc = XCreateGC(display, shapeMask, 0, 0); XCopyPlane(display, pixmap, shapeMask, tempGc, 0, 0, width, height, 0, 0, 1); #ifdef SHAPE XShapeCombineMask(display, window, 0, 0, 0, shapeMask, ShapeUnion); #endif // SHAPE imlib_context_set_drawable(pixmap); }
static void drawImages(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); imagestruct *ip = &ims[MI_SCREEN(mi)]; GC gc = (message && *message) ? MI_GC(mi) : ip->bgGC; int i; MI_CLEARWINDOWCOLORMAPFAST(mi, gc, ip->black); for (i = 0; i < ip->iconcount; i++) { if (ip->icons[i].x >= 0) { if (message && *message) { if (MI_NPIXELS(mi) > 2) XSetForeground(display, gc, MI_PIXEL(mi, ip->icons[i].color)); else XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); XCopyPlane(display, ip->pixmap, window, gc, 0, 0, ip->pixw, ip->pixh, ip->pixw * ip->icons[i].x + ip->image_offset.x, ip->pixh * ip->icons[i].y + ip->image_offset.y, 1L); } else if (ip->logo != NULL) { if (MI_NPIXELS(mi) <= 2) XSetForeground(display, gc, MI_WHITE_PIXEL(mi)); else if (ip->graphics_format < IS_XPM) XSetForeground(display, gc, MI_PIXEL(mi, ip->icons[i].color)); (void) XPutImage(display, window, gc, ip->logo, 0, 0, ip->pixw * ip->icons[i].x + ip->image_offset.x, ip->pixh * ip->icons[i].y + ip->image_offset.y, ip->pixw, ip->pixh); } } } }
Pixmap XmuCreatePixmapFromBitmap(Display *dpy, Drawable d, Pixmap bitmap, unsigned int width, unsigned int height, unsigned int depth, unsigned long fore, unsigned long back) /* * dpy - connection to X server * d - drawable indicating screen * bitmap - single plane pixmap * width, height - dimensions of bitmap and pixmap * depth - depth of pixmap to create * fore, back - colors to use */ { Pixmap pixmap; pixmap = XCreatePixmap (dpy, d, width, height, depth); if (pixmap != None) { GC gc; XGCValues xgcv; xgcv.foreground = fore; xgcv.background = back; xgcv.graphics_exposures = False; gc = XCreateGC (dpy, d, (GCForeground | GCBackground | GCGraphicsExposures), &xgcv); if (gc) { XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); XFreeGC (dpy, gc); } else { XFreePixmap (dpy, pixmap); pixmap = None; } } return pixmap; }
void TkpDisplayButton( ClientData clientData) /* Information about widget. */ { register TkButton *butPtr = (TkButton *) clientData; GC gc; Tk_3DBorder border; Pixmap pixmap; int x = 0; /* Initialization only needed to stop compiler * warning. */ int y, relief; Tk_Window tkwin = butPtr->tkwin; int width, height, fullWidth, fullHeight; int textXOffset, textYOffset; int haveImage = 0, haveText = 0; int offset; /* 1 means this is a button widget, so we * offset the text to make the button appear * to move up and down as the relief * changes. */ int imageWidth, imageHeight; int imageXOffset = 0, imageYOffset = 0; /* image information that will be used to * restrict disabled pixmap as well */ butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { gc = butPtr->disabledGC; } else if ((butPtr->state == STATE_ACTIVE) && !Tk_StrictMotif(butPtr->tkwin)) { gc = butPtr->activeTextGC; border = butPtr->activeBorder; } else { gc = butPtr->normalTextGC; } if ((butPtr->flags & SELECTED) && (butPtr->state != STATE_ACTIVE) && (butPtr->selectBorder != NULL) && !butPtr->indicatorOn) { border = butPtr->selectBorder; } /* * Override the relief specified for the button if this is a checkbutton * or radiobutton and there's no indicator. The new relief is as follows: * If the button is select --> "sunken" * If relief==overrelief --> relief * Otherwise --> overrelief * * The effect we are trying to achieve is as follows: * * value mouse-over? --> relief * ------- ------------ -------- * off no flat * off yes raised * on no sunken * on yes sunken * * This is accomplished by configuring the checkbutton or radiobutton like * this: * * -indicatoron 0 -overrelief raised -offrelief flat * * Bindings (see library/button.tcl) will copy the -overrelief into * -relief on mouseover. Hence, we can tell if we are in mouse-over by * comparing relief against overRelief. This is an aweful kludge, but it * gives use the desired behavior while keeping the code backwards * compatible. */ relief = butPtr->relief; if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { if (butPtr->flags & SELECTED) { relief = TK_RELIEF_SUNKEN; } else if (butPtr->overRelief != relief) { relief = butPtr->offRelief; } } offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin); /* * In order to avoid screen flashes, this function redraws the button in a * pixmap, then copies the pixmap to the screen in a single operation. * This means that there's no point in time where the on-screen image has * been cleared. */ pixmap = Tk_GetPixmap(butPtr->display, Tk_WindowId(tkwin), Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin)); Tk_Fill3DRectangle(tkwin, pixmap, border, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT); /* * Display image or bitmap or text for button. */ if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } imageWidth = width; imageHeight = height; haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { textXOffset = 0; textYOffset = 0; fullWidth = 0; fullHeight = 0; switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: /* * Image is above or below text. */ if (butPtr->compound == COMPOUND_TOP) { textYOffset = height + butPtr->padY; } else { imageYOffset = butPtr->textHeight + butPtr->padY; } fullHeight = height + butPtr->textHeight + butPtr->padY; fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth); textXOffset = (fullWidth - butPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; break; case COMPOUND_LEFT: case COMPOUND_RIGHT: /* * Image is left or right of text. */ if (butPtr->compound == COMPOUND_LEFT) { textXOffset = width + butPtr->padX; } else { imageXOffset = butPtr->textWidth + butPtr->padX; } fullWidth = butPtr->textWidth + butPtr->padX + width; fullHeight = (height > butPtr->textHeight ? height : butPtr->textHeight); textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; case COMPOUND_CENTER: /* * Image and text are superimposed. */ fullWidth = (width > butPtr->textWidth ? width : butPtr->textWidth); fullHeight = (height > butPtr->textHeight ? height : butPtr->textHeight); textXOffset = (fullWidth - butPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; textYOffset = (fullHeight - butPtr->textHeight)/2; imageYOffset = (fullHeight - height)/2; break; case COMPOUND_NONE: break; } TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y); x += butPtr->indicatorSpace; x += offset; y += offset; if (relief == TK_RELIEF_RAISED) { x -= offset; y -= offset; } else if (relief == TK_RELIEF_SUNKEN) { x += offset; y += offset; } imageXOffset += x; imageYOffset += y; if (butPtr->image != NULL) { /* * Do boundary clipping, so that Tk_RedrawImage is passed valid * coordinates. [Bug 979239] */ if (imageXOffset < 0) { imageXOffset = 0; } if (imageYOffset < 0) { imageYOffset = 0; } if (width > Tk_Width(tkwin)) { width = Tk_Width(tkwin); } if (height > Tk_Height(tkwin)) { height = Tk_Height(tkwin); } if ((width + imageXOffset) > Tk_Width(tkwin)) { imageXOffset = Tk_Width(tkwin) - width; } if ((height + imageYOffset) > Tk_Height(tkwin)) { imageYOffset = Tk_Height(tkwin) - height; } if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) { Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } } else { XSetClipOrigin(butPtr->display, gc, imageXOffset, imageYOffset); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0, (unsigned int) width, (unsigned int) height, imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, gc, 0, 0); } Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1); Tk_UnderlineTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x + textXOffset, y + textYOffset, butPtr->underline); y += fullHeight/2; } else { if (haveImage) { TkComputeAnchor(butPtr->anchor, tkwin, 0, 0, butPtr->indicatorSpace + width, height, &x, &y); x += butPtr->indicatorSpace; x += offset; y += offset; if (relief == TK_RELIEF_RAISED) { x -= offset; y -= offset; } else if (relief == TK_RELIEF_SUNKEN) { x += offset; y += offset; } imageXOffset += x; imageYOffset += y; if (butPtr->image != NULL) { /* * Do boundary clipping, so that Tk_RedrawImage is passed * valid coordinates. [Bug 979239] */ if (imageXOffset < 0) { imageXOffset = 0; } if (imageYOffset < 0) { imageYOffset = 0; } if (width > Tk_Width(tkwin)) { width = Tk_Width(tkwin); } if (height > Tk_Height(tkwin)) { height = Tk_Height(tkwin); } if ((width + imageXOffset) > Tk_Width(tkwin)) { imageXOffset = Tk_Width(tkwin) - width; } if ((height + imageYOffset) > Tk_Height(tkwin)) { imageYOffset = Tk_Height(tkwin) - height; } if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else if ((butPtr->tristateImage != NULL) && (butPtr->flags & TRISTATED)) { Tk_RedrawImage(butPtr->tristateImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } else { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); } } else { XSetClipOrigin(butPtr->display, gc, x, y); XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, gc, 0, 0, (unsigned int) width, (unsigned int) height, x, y, 1); XSetClipOrigin(butPtr->display, gc, 0, 0); } y += height/2; } else { TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, butPtr->indicatorSpace + butPtr->textWidth, butPtr->textHeight, &x, &y); x += butPtr->indicatorSpace; x += offset; y += offset; if (relief == TK_RELIEF_RAISED) { x -= offset; y -= offset; } else if (relief == TK_RELIEF_SUNKEN) { x += offset; y += offset; } Tk_DrawTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x, y, 0, -1); Tk_UnderlineTextLayout(butPtr->display, pixmap, gc, butPtr->textLayout, x, y, butPtr->underline); y += butPtr->textHeight/2; } } /* * Draw the indicator for check buttons and radio buttons. At this point, * x and y refer to the top-left corner of the text or image or bitmap. */ if ((butPtr->type == TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) { TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; XColor *selColor = NULL; if (selBorder != NULL) { selColor = selBorder->bgColorPtr; } x -= butPtr->indicatorSpace/2; y = Tk_Height(tkwin)/2; TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y, border, butPtr->normalFg, selColor, butPtr->disabledFg, ((butPtr->flags & SELECTED) ? 1 : (butPtr->flags & TRISTATED) ? 2 : 0), (butPtr->state == STATE_DISABLED), CHECK_BUTTON); } } else if ((butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn) { if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) { TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; XColor *selColor = NULL; if (selBorder != NULL) { selColor = selBorder->bgColorPtr; } x -= butPtr->indicatorSpace/2; y = Tk_Height(tkwin)/2; TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y, border, butPtr->normalFg, selColor, butPtr->disabledFg, ((butPtr->flags & SELECTED) ? 1 : (butPtr->flags & TRISTATED) ? 2 : 0), (butPtr->state == STATE_DISABLED), RADIO_BUTTON); } } /* * If the button is disabled with a stipple rather than a special * foreground color, generate the stippled effect. If the widget is * selected and we use a different background color when selected, must * temporarily modify the GC so the stippling is the right color. */ if ((butPtr->state == STATE_DISABLED) && ((butPtr->disabledFg == NULL) || (butPtr->image != NULL))) { if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->selectBorder)->pixel); } /* * Stipple the whole button if no disabledFg was specified, otherwise * restrict stippling only to displayed image */ if (butPtr->disabledFg == NULL) { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin)); } else { XFillRectangle(butPtr->display, pixmap, butPtr->stippleGC, imageXOffset, imageYOffset, (unsigned) imageWidth, (unsigned) imageHeight); } if ((butPtr->flags & SELECTED) && !butPtr->indicatorOn && (butPtr->selectBorder != NULL)) { XSetForeground(butPtr->display, butPtr->stippleGC, Tk_3DBorderColor(butPtr->normalBorder)->pixel); } } /* * Draw the border and traversal highlight last. This way, if the button's * contents overflow they'll be covered up by the border. This code is * complicated by the possible combinations of focus highlight and default * rings. We draw the focus and highlight rings using the highlight border * and highlight foreground color. */ if (relief != TK_RELIEF_FLAT) { int inset = butPtr->highlightWidth; if (butPtr->defaultState == DEFAULT_ACTIVE) { /* * Draw the default ring with 2 pixels of space between the * default ring and the button and the default ring and the focus * ring. Note that we need to explicitly draw the space in the * highlightBorder color to ensure that we overwrite any overflow * text and/or a different button background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, 1, TK_RELIEF_SUNKEN); inset++; Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, 2, TK_RELIEF_FLAT); inset += 2; } else if (butPtr->defaultState == DEFAULT_NORMAL) { /* * Leave room for the default ring and write over any text or * background color. */ Tk_Draw3DRectangle(tkwin, pixmap, butPtr->highlightBorder, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 5, TK_RELIEF_FLAT); inset += 5; } /* * Draw the button border. */ Tk_Draw3DRectangle(tkwin, pixmap, border, inset, inset, Tk_Width(tkwin) - 2*inset, Tk_Height(tkwin) - 2*inset, butPtr->borderWidth, relief); } if (butPtr->highlightWidth > 0) { GC gc; if (butPtr->flags & GOT_FOCUS) { gc = Tk_GCForColor(butPtr->highlightColorPtr, pixmap); } else { gc = Tk_GCForColor(Tk_3DBorderColor(butPtr->highlightBorder), pixmap); } /* * Make sure the focus ring shrink-wraps the actual button, not the * padding space left for a default ring. */ if (butPtr->defaultState == DEFAULT_NORMAL) { TkDrawInsetFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap, 5); } else { Tk_DrawFocusHighlight(tkwin, gc, butPtr->highlightWidth, pixmap); } } /* * Copy the information from the off-screen pixmap onto the screen, then * delete the pixmap. */ XCopyArea(butPtr->display, pixmap, Tk_WindowId(tkwin), butPtr->copyGC, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0); Tk_FreePixmap(butPtr->display, pixmap); }
/* * Almost the same as XmGetPixmap() above, but this time the programmer can * even control the depth of the pixmap she/he wants. */ extern Pixmap XmGetPixmapByDepth(Screen *screen, char *image_name, Pixel foreground, Pixel background, int depth) { LTPixmapDescRec PixmapDesc; LTPixmapDesc PixmapValue; LTImageValue ImageDesc; int image_depth; char *pathname_to_pixmap; unsigned int bitmap_width, bitmap_height; int x_hot, y_hot; XImage *image; Pixmap new_pix, tmp, mask; GC gc; XGCValues values; #ifdef NONSTANDARD_CONVERTERS XpmColorSymbol xpm_colour_symbols[3]; XpmAttributes xpm_attrib; #endif /* NONSTANDARD_CONVERTERS */ values.foreground = foreground; values.background = background; if (PixmapCache == NULL) { LTSetupPixmapCache(); } if (image_name == NULL) { return XmUNSPECIFIED_PIXMAP; } /* * First, we check the pixmap cache to see if such a pixmap is already * there. Therefore we fill in a pixmap description but only use the * first set of fields in the description structure. The second set will * contain information about the pixmap, if a pixmap, as described by the * first set, is already in the cache. */ PixmapDesc.image_name = image_name; PixmapDesc.screen = screen; PixmapDesc.foreground = foreground; PixmapDesc.background = background; PixmapDesc.depth = depth; if (_LTHashTableLookupItem(PixmapCache, (LTHashItemID) & PixmapDesc, (LTHashItemValue *) & PixmapValue)) { /* * There's a pixmap in the cache so we use it and increment its * reference count. */ (PixmapValue->ref_count)++; #if 0 DEBUGOUT(_LtDebug0(__FILE__, NULL, "XmGetPixmapByDepth(scr %p, %s, dpy %p, fg %p, bg %p, d %d) -> %p, refcnt %d\n", screen, image_name, DisplayOfScreen(screen), foreground, background, depth, PixmapValue->pixmap, PixmapValue->ref_count)); #endif return PixmapValue->pixmap; } /* * Okay, we had no luck. Now check the image cache. */ ImageDesc = LTGetImageFromCache(image_name); if (ImageDesc != NULL) { /* * A match from the image cache. Now create the pixmap, add it to * the cache, and return it. */ image = ImageDesc->image; if (image->format == XYBitmap) { image_depth = 1; } else { image_depth = image->depth; } /* create the pixmap */ new_pix = _XmAllocScratchPixmap((XmScreen)XmGetXmScreen(screen), depth, image->width, image->height); tmp = _XmAllocScratchPixmap((XmScreen)XmGetXmScreen(screen), depth, image->width, image->height); gc = XCreateGC(DisplayOfScreen(screen), tmp, 0, NULL); /* move the image information into a temporary pixmap */ XPutImage(DisplayOfScreen(screen), tmp, gc, image, 0, 0, 0, 0, image->width, image->height); XFreeGC(DisplayOfScreen(screen), gc); values.foreground = background; values.background = foreground; gc = XCreateGC(DisplayOfScreen(screen), new_pix, GCForeground | GCBackground, &values); if (image_depth == 1) { XCopyPlane(DisplayOfScreen(screen), tmp, new_pix, gc, 0, 0, image->width, image->height, 0, 0, 1); } else { XCopyArea(DisplayOfScreen(screen), tmp, new_pix, gc, 0, 0, image->width, image->height, 0, 0); } XFreeGC(DisplayOfScreen(screen), gc); /* add the pixmap to the cache */ _LTAddPixmapToCache(image_name, new_pix, screen, foreground, background, depth, image->width, image->height, ImageDesc->hot_x, ImageDesc->hot_y); DEBUGOUT(_LtDebug0(__FILE__, NULL, "XmGetPixmapByDepth(scr %p, %s, dpy %p, fg %p, bg %p, d %d) -> %p new\n", screen, image_name, DisplayOfScreen(screen), foreground, background, depth, new_pix)); return new_pix; } /* since it wasn't in either cache, we search for the file */ /* make sure the search path is there */ if (!_search_path) { _LTCreateSearchPath(); } if (image_name[0] == '/') /* an absolute pathname */ { pathname_to_pixmap = XtNewString(image_name); } else { SubstitutionRec subs[1]; subs[0].match = 'B'; subs[0].substitution = XtNewString(image_name); pathname_to_pixmap = XtResolvePathname(DisplayOfScreen(screen), "bitmaps", NULL, NULL, _search_path, subs, 1, NULL); XtFree(subs[0].substitution); } /* this breaks if X isn't where it's supposed to be. Don't dump core, * just return */ if (pathname_to_pixmap == NULL || strlen(pathname_to_pixmap) == 0) { return XmUNSPECIFIED_PIXMAP; } DEBUGOUT(_LtDebug(__FILE__, NULL, "pathname found is %s\n", pathname_to_pixmap)); /* * For 1.2 converting XPMs to pixmaps is an extension (standard * Motif dosen't read XPMs until version 2) so only do it if * NONSTANDARD_CONVERTERS is defined */ #ifdef NONSTANDARD_CONVERTERS /* Try for an XPM file, then a bitmap */ /* Set up symbolic names for foreground & background colours */ xpm_colour_symbols[0].name = "background"; xpm_colour_symbols[0].value = 0; xpm_colour_symbols[0].pixel = background ; xpm_colour_symbols[1].name = "foreground"; xpm_colour_symbols[1].value = 0; xpm_colour_symbols[1].pixel = foreground ; xpm_colour_symbols[2].name = NULL; xpm_colour_symbols[2].value = "None"; xpm_colour_symbols[2].pixel = background ; xpm_attrib.colorsymbols = xpm_colour_symbols; xpm_attrib.numsymbols = XtNumber(xpm_colour_symbols); xpm_attrib.depth = depth; xpm_attrib.closeness = 40000; xpm_attrib.valuemask = ( XpmSize | XpmReturnPixels | XpmColorSymbols | XpmCloseness | XpmDepth ); if (XpmReadFileToPixmap(DisplayOfScreen(screen), RootWindowOfScreen(screen), pathname_to_pixmap, &new_pix, &mask, &xpm_attrib) == XpmSuccess) { /* add the pixmap to the cache */ _LTAddPixmapToCache(image_name, new_pix, screen, foreground, background, depth, xpm_attrib.width, xpm_attrib.height, xpm_attrib.x_hotspot, xpm_attrib.y_hotspot); } else #endif /* NONSTANDARD_CONVERTERS */ if (XReadBitmapFile(DisplayOfScreen(screen), RootWindowOfScreen(screen), pathname_to_pixmap, &bitmap_width, &bitmap_height, &tmp, &x_hot, &y_hot) == BitmapSuccess) { new_pix = _XmAllocScratchPixmap((XmScreen)XmGetXmScreen(screen), depth, bitmap_width, bitmap_height); gc = XCreateGC(DisplayOfScreen(screen), new_pix, GCForeground | GCBackground, &values); XCopyPlane(DisplayOfScreen(screen), tmp, new_pix, gc, 0, 0, bitmap_width, bitmap_height, 0, 0, 1); XFreeGC(DisplayOfScreen(screen), gc); /* add the pixmap to the cache */ _LTAddPixmapToCache(image_name, new_pix, screen, foreground, background, depth, bitmap_width, bitmap_height, 0, 0 /* FIX ME! hot_x, hot_y! */ ); } else { _XmWarning(NULL, "Couldn't load the pixmap %s.\n", pathname_to_pixmap); new_pix = XmUNSPECIFIED_PIXMAP; } XtFree(pathname_to_pixmap); DEBUGOUT(_LtDebug0(__FILE__, NULL, "XmGetPixmapByDepth(scr %p, %s, dpy %p, fg %p, bg %p, d %d) -> %p new2\n", screen, image_name, DisplayOfScreen(screen), foreground, background, depth, new_pix)); return new_pix; }
void TkpDisplayMenuButton( ClientData clientData) /* Information about widget. */ { TkMenuButton *butPtr = (TkMenuButton *) clientData; Tk_Window tkwin = butPtr->tkwin; TkWindow * winPtr; Pixmap pixmap; MacMenuButton * mbPtr = (MacMenuButton *) butPtr; GWorldPtr dstPort; CGrafPtr saveWorld; GDHandle saveDevice; int hasImageOrBitmap = 0; int width, height; int err; ControlButtonGraphicAlignment theAlignment; Rect paneRect, cntrRect; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; } pixmap = ( Pixmap )Tk_WindowId(tkwin); GetGWorld(&saveWorld, &saveDevice); dstPort = TkMacOSXGetDrawablePort(Tk_WindowId(tkwin)); SetGWorld(dstPort, NULL); TkMacOSXSetUpClippingRgn(Tk_WindowId(tkwin)); winPtr=(TkWindow *)butPtr->tkwin; paneRect.left=winPtr->privatePtr->xOff; paneRect.top=winPtr->privatePtr->yOff; paneRect.right=paneRect.left+Tk_Width(butPtr->tkwin)-1; paneRect.bottom=paneRect.top+Tk_Height(butPtr->tkwin)-1; cntrRect=paneRect; cntrRect.left+=butPtr->inset; cntrRect.top+=butPtr->inset; cntrRect.right-=butPtr->inset; cntrRect.bottom-=butPtr->inset; if (mbPtr->userPane) { MenuButtonControlParams params; bzero(¶ms, sizeof(params)); ComputeMenuButtonControlParams(butPtr, ¶ms ); if (bcmp(¶ms,&mbPtr->params,sizeof(params))) { if (mbPtr->userPane) { DisposeControl(mbPtr->userPane); mbPtr->userPane = NULL; mbPtr->control = NULL; } } } if (!mbPtr->userPane) { if (MenuButtonInitControl(mbPtr,&paneRect,&cntrRect ) ) { fprintf(stderr,"Init Control failed\n" ); return; } } SetControlBounds(mbPtr->userPane,&paneRect); SetControlBounds(mbPtr->control,&cntrRect); /* * We need to cache the title and its style */ if (!(mbPtr->flags&2)) { ControlTitleParams titleParams; int titleChanged; int styleChanged; ComputeControlTitleParams(butPtr,&titleParams); CompareControlTitleParams(&titleParams,&mbPtr->titleParams, &titleChanged,&styleChanged); if (titleChanged) { CFStringRef cf; cf = CFStringCreateWithCString(NULL, titleParams.title, kCFStringEncodingUTF8); if (hasImageOrBitmap) { SetControlTitleWithCFString(mbPtr->control, cf); } else { SetMenuItemTextWithCFString(mbPtr->menuRef, 1, cf); } CFRelease(cf); bcopy(titleParams.title,mbPtr->titleParams.title,titleParams.len+1); mbPtr->titleParams.len = titleParams.len; } if ((titleChanged||styleChanged) && titleParams .len) { if (hasImageOrBitmap) { if ((err=SetControlFontStyle(mbPtr->control,&titleParams.style))!=noErr) { fprintf(stderr,"SetControlFontStyle failed %d\n", err); return; } } bcopy(&titleParams.style,&mbPtr->titleParams.style,sizeof(titleParams.style)); } } if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, &width, &height); hasImageOrBitmap = 1; } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); hasImageOrBitmap = 1; } if (hasImageOrBitmap) { mbPtr->picParams.srcRect.right = width; mbPtr->picParams.srcRect.bottom = height; /* Set the flag to circumvent clipping and bounds problems with OS 10.0.4 */ tkPictureIsOpen = 1; if (!(mbPtr->bevelButtonContent.u.picture = OpenCPicture(&mbPtr->picParams)) ) { fprintf(stderr,"OpenCPicture failed\n"); } /* * TO DO - There is one case where XCopyPlane calls CopyDeepMask, * which does not get recorded in the picture. So the bitmap code * will fail in that case. */ if (butPtr->image != NULL) { Tk_RedrawImage(butPtr->image, 0, 0, width, height, pixmap, 0, 0); } else { XCopyPlane(butPtr->display, butPtr->bitmap, pixmap, NULL, 0, 0, (unsigned int) width, (unsigned int) height, 0, 0, 1); } ClosePicture(); tkPictureIsOpen = 0; if ( (err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonContentTag, sizeof(ControlButtonContentInfo), (char *) &mbPtr->bevelButtonContent)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonContent failed, %d\n", err ); } switch (butPtr->anchor) { case TK_ANCHOR_N: theAlignment = kControlBevelButtonAlignTop; break; case TK_ANCHOR_NE: theAlignment = kControlBevelButtonAlignTopRight; break; case TK_ANCHOR_E: theAlignment = kControlBevelButtonAlignRight; break; case TK_ANCHOR_SE: theAlignment = kControlBevelButtonAlignBottomRight; break; case TK_ANCHOR_S: theAlignment = kControlBevelButtonAlignBottom; break; case TK_ANCHOR_SW: theAlignment = kControlBevelButtonAlignBottomLeft; break; case TK_ANCHOR_W: theAlignment = kControlBevelButtonAlignLeft; break; case TK_ANCHOR_NW: theAlignment = kControlBevelButtonAlignTopLeft; break; case TK_ANCHOR_CENTER: theAlignment = kControlBevelButtonAlignCenter; break; } if ((err=SetControlData(mbPtr->control, kControlButtonPart, kControlBevelButtonGraphicAlignTag, sizeof(ControlButtonGraphicAlignment), (char *) &theAlignment)) != noErr ) { fprintf(stderr,"SetControlData BevelButtonGraphicAlign failed, %d\n", err ); } } if (butPtr->flags & GOT_FOCUS) { HiliteControl(mbPtr->control,kControlButtonPart); } else { HiliteControl(mbPtr->control,kControlNoPart); } UpdateControlColors(mbPtr); if (mbPtr->flags&2) { ShowControl(mbPtr->control); ShowControl(mbPtr->userPane); mbPtr->flags ^= 2; } else { Draw1Control(mbPtr->userPane); SetControlVisibility(mbPtr->control, true, true); } if (hasImageOrBitmap) { KillPicture(mbPtr->bevelButtonContent.u.picture); } SetGWorld(saveWorld, saveDevice); }