static void paint_fly(ModeInfo * mi, Fly * f) { EyeScrInfo *ep = &eye_info[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int x = f->x, y = f->y; if (MI_IS_ICONIC(mi)) { /* don't need to unpaint when iconic * ep->flyGC has stipple set, don't use when iconic */ XSetForeground(display, MI_GC(mi), f->pixel); XFillArc(display, window, MI_GC(mi), x, y, f->width, f->height, 90 * 64, 360 * 64); } else { unpaint_fly(mi, f); XSetForeground(display, ep->flyGC, f->pixel); #ifdef XBM_GRELB if (ep->fly2pix != None) { XSetStipple(display, ep->flyGC, (f->vy <= 0) ? ep->flypix : ep->fly2pix); } else #endif XSetStipple(display, ep->flyGC, ep->flypix); XSetTSOrigin(display, ep->flyGC, x, y); #ifdef FLASH XSetFillStyle(display, ep->flyGC, FillStippled); #else XSetFillStyle(display, ep->flyGC, FillOpaqueStippled); #endif XFillRectangle(display, window, ep->flyGC, x, y, f->width, f->height); XFlush(display); } }
void xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y) { xfGlyph* xf_glyph; xfInfo* xfi = ((xfContext*) context)->xfi; xf_glyph = (xfGlyph*) glyph; XSetStipple(xfi->display, xfi->gc, xf_glyph->pixmap); XSetTSOrigin(xfi->display, xfi->gc, x, y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, x, y, glyph->cx, glyph->cy); XSetStipple(xfi->display, xfi->gc, xfi->bitmap_mono); }
void PainterRep::PrepareFill(const Pattern* p) { PatternRep& pr = *p->rep(); XDisplay* dpy = display->rep()->display_; if (pr.pixmap_ == nil) { XSetFillStyle(dpy, fillgc, FillSolid); } else if (fillbg) { XSetStipple(dpy, fillgc, pr.pixmap_); XSetFillStyle(dpy, fillgc, FillOpaqueStippled); } else { XSetStipple(dpy, fillgc, pr.pixmap_); XSetFillStyle(dpy, fillgc, FillStippled); } }
void FillRct(capd::krak::Rct *r, INT pattern, INT color) /* Function FillRct fills the rectangle r with the given pattern in the given color. It does not change the current foreground color */ { if (isgraphic) { XSetStipple(display,drawgc,stipple[pattern]); XSetForeground(display,drawgc,exact_defs[color].pixel); XFillRectangle(display,win,drawgc,r->lti,r->ltj+top_marg_size,r->rbi-r->lti+2,r->rbj-r->ltj+2+top_marg_size); XSetForeground(display,drawgc,exact_defs[c_fgcol].pixel); XSetStipple(display,drawgc,stipple[SOLID_P]); } }
void rf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y) { #ifdef RF_GLYPH rfGlyph* rf_glyph; rfContext* rfi = (rfContext*) context; rf_glyph = (rfGlyph*) glyph; XSetStipple(rfi->display, rfi->gc, rf_glyph->pixmap); XSetTSOrigin(rfi->display, rfi->gc, x, y); XFillRectangle(rfi->display, rfi->drawing, rfi->gc, x, y, glyph->cx, glyph->cy); XSetStipple(rfi->display, rfi->gc, rfi->bitmap_mono); #endif }
void xf_Glyph_Draw(rdpContext* context, rdpGlyph* glyph, int x, int y) { xfGlyph* xf_glyph; xfContext* xfc = (xfContext*) context; xf_glyph = (xfGlyph*) glyph; xf_lock_x11(xfc, FALSE); XSetStipple(xfc->display, xfc->gc, xf_glyph->pixmap); XSetTSOrigin(xfc->display, xfc->gc, x, y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, glyph->cx, glyph->cy); XSetStipple(xfc->display, xfc->gc, xfc->bitmap_mono); xf_unlock_x11(xfc, FALSE); }
static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x, UINT32 y, UINT32 w, UINT32 h, UINT32 sx, UINT32 sy, BOOL fOpRedundant) { xfGlyph* xf_glyph; xfContext* xfc = (xfContext*) context; xf_glyph = (xfGlyph*) glyph; xf_lock_x11(xfc, FALSE); if (!fOpRedundant) { XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XFillRectangle(xfc->display, xfc->drawable, xfc->gc, x, y, w, h); } XSetFillStyle(xfc->display, xfc->gc, FillStippled); XSetStipple(xfc->display, xfc->gc, xf_glyph->pixmap); if (sx || sy) WLog_ERR(TAG, ""); //XSetClipOrigin(xfc->display, xfc->gc, sx, sy); XSetTSOrigin(xfc->display, xfc->gc, x, y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, w, h); xf_unlock_x11(xfc, FALSE); return TRUE; }
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap ) { static char stipple_data[] = { 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA }; GC gc; Pixmap ipixmap, stipple; unsigned width, height, depth; Window window; /* These return values */ unsigned border; /* from XGetGeometry() */ int x, y; /* are not needed. */ ipixmap = 0; if ( NULL == display || 0 == pixmap ) return ipixmap; if ( 0 == XGetGeometry( display, pixmap, &window, &x, &y, &width, &height, &border, &depth ) ) return ipixmap; /* BadDrawable: probably an invalid pixmap */ /* Get the stipple pixmap to be used to 'gray-out' the argument pixmap. */ stipple = XCreateBitmapFromData( display, pixmap, stipple_data, 16, 16 ); if ( 0 != stipple ) { gc = XCreateGC( display, pixmap, (XtGCMask)0, NULL ); if ( NULL != gc ) { /* Create an identical copy of the argument pixmap. */ ipixmap = XCreatePixmap( display, pixmap, width, height, depth ); if ( 0 != ipixmap ) { /* Copy the argument pixmap into the new pixmap. */ XCopyArea( display, pixmap, ipixmap, gc, 0, 0, width, height, 0, 0 ); /* Refill the new pixmap using the stipple algorithm/pixmap. */ XSetStipple( display, gc, stipple ); XSetFillStyle( display, gc, FillStippled ); XFillRectangle( display, ipixmap, gc, 0, 0, width, height ); } XFreeGC( display, gc ); } XFreePixmap( display, stipple ); } return ipixmap; }
int XChangeDither(Display *display, GC gc, int dither) { if (!DITHERINIT) { fprintf(stderr, "XChange Error: Init Not Called\n"); exit(-1); } if (dither >= XDitherMax || dither < 0) { fprintf(stderr, "Dither %d, out of range\n",dither); return (-1); } XSetStipple(display, gc, XDither[dither]); return (1); }
/**************************************************************************** Fill the area covered by the sprite with the given color. ****************************************************************************/ void canvas_fog_sprite_area(struct canvas *pcanvas, struct sprite *psprite, int canvas_x, int canvas_y) { if (psprite->has_mask) { XSetClipOrigin(display, fill_tile_gc, canvas_x, canvas_y); XSetClipMask(display, fill_tile_gc, psprite->mask); } XSetStipple(display, fill_tile_gc, gray50); XSetTSOrigin(display, fill_tile_gc, canvas_x, canvas_y); XSetForeground(display, fill_tile_gc, get_color(tileset, COLOR_MAPVIEW_UNKNOWN)->color.pixel); XFillRectangle(display, pcanvas->pixmap, fill_tile_gc, canvas_x, canvas_y, psprite->width, psprite->height); if (psprite->has_mask) { XSetClipMask(display, fill_tile_gc, None); } }
static PyObject * PaxGC_SetStipple(PaxGCObject *self, PyObject*args) { PyObject *arg1; if (self->shared) { PyErr_SetString(PyExc_TypeError, "can't modify shared GC"); return NULL; } if (!PyArg_ParseTuple(args, "O", &arg1)) return NULL; if (!PaxPixmap_Check(arg1)) { if (!PyErr_Occurred()) PyErr_SetString(PyExc_TypeError, "arg1 should be Pixmap"); return NULL; } XSetStipple(self->display, self->gc, PaxPixmap_AsPixmap(arg1)); Py_INCREF(Py_None); return Py_None; }
void InitX(void) { int screen, dum; Pixmap check; display = XOpenDisplay(""); screen = DefaultScreen(display); cmap = DefaultColormap(display, screen); white = WhitePixel(display, screen); black = BlackPixel(display, screen); XGetGeometry(display, DefaultRootWindow(display), &root, &dum, &dum, &width, &height, (unsigned int *)&dum, &depth); rootmap = XCreatePixmap(display, root, width, height, depth); cutmap = XCreatePixmap(display, root, width, height, depth); scratch = XCreateWindow(display, root, 0, 0, WINW, WINH, 0, depth, InputOutput, CopyFromParent, 0, NULL); XSelectInput(display, scratch, ExposureMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask); XMapRaised(display, scratch); scratchmap = XCreatePixmap(display, root, WINW, WINH, depth); gc = XCreateGC(display, root, 0, 0); XSetSubwindowMode(display, gc, IncludeInferiors); shadow_gc = XCreateGC(display, root, 0, 0); XSetFillStyle(display, shadow_gc, FillStippled); check = XCreateBitmapFromData(display, root, check_bits, check_width, check_height); XSetStipple(display, shadow_gc, check); XGrabButton(display, Button1, Mod1Mask, DefaultRootWindow(display), False, PointerMotionMask | ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, DefaultRootWindow(display), None); }
bool XPlatformWindow::setup_gcs() { // create 3 gc's and set their attributes unsigned long valuemask = 0; XGCValues values; _gc = XCreateGC(_display, _xwindow, valuemask, &values); XSetFont(_display, _gc, _font_info->fid); XSetForeground(_display, _gc, BlackPixel(_display, _screen_num)); XSetBackground(_display, _gc, WhitePixel(_display, _screen_num)); // 16x16 grey stipple pixmap (16x16 is preferred stipple size) const int grey_width = 16; const int grey_height = 16; static char grey_bits[] = { 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa}; Pixmap stipple = XCreateBitmapFromData(_display, _xwindow, grey_bits, grey_width, grey_height); XSetStipple(_display, _gc, stipple); _black= BlackPixel(_display, _screen_num); _white= WhitePixel(_display, _screen_num); _is_mono = DefaultDepth(_display, _screen_num) == 1; if (_is_mono) _red= _yellow= _gray= _black; else { Colormap cmap= DefaultColormap(_display, _screen_num); XColor col1, col2; _red= XAllocNamedColor(_display, cmap, "red", &col1, &col2) ? col1.pixel : _black; _yellow= XAllocNamedColor(_display, cmap, "gold", &col1, &col2) ? col1.pixel : _black; _gray= XAllocNamedColor(_display, cmap, "gray", &col1, &col2) ? col1.pixel : _black; } return true; }
static int XRotPaintAlignedString(Display* dpy, XFontStruct* font, float angle, Drawable drawable, GC gc, int x, int y, char* text, int align, int bg) { int i; GC my_gc; int xp, yp; float hot_x, hot_y; float hot_xp, hot_yp; float sin_angle, cos_angle; RotatedTextItem *item; Pixmap bitmap_to_paint; /* return early for NULL/empty strings */ if(text==NULL) return 0; if(strlen(text)==0) return 0; /* manipulate angle to 0<=angle<360 degrees */ while(angle<0) angle+=360; while(angle>=360) angle-=360; angle*=M_PI/180; /* horizontal text made easy */ if(angle==0. && style.magnify==1.) return(XRotDrawHorizontalString(dpy, font, drawable, gc, x, y, text, align, bg)); /* get a rotated bitmap */ item=XRotRetrieveFromCache(dpy, font, angle, text, align); if(item==NULL) return 0; /* this gc has similar properties to the user's gc */ my_gc=XCreateGC(dpy, drawable, 0, 0); XCopyGC(dpy, gc, GCForeground|GCBackground|GCFunction|GCPlaneMask, my_gc); /* alignment : which point (hot_x, hot_y) relative to bitmap centre coincides with user's specified point? */ /* y position */ if(align==TLEFT || align==TCENTRE || align==TRIGHT) hot_y=(float)item->rows_in/2*style.magnify; else if(align==MLEFT || align==MCENTRE || align==MRIGHT) hot_y=0; else if(align==BLEFT || align==BCENTRE || align==BRIGHT) hot_y=-(float)item->rows_in/2*style.magnify; else hot_y=-((float)item->rows_in/2-(float)font->descent)*style.magnify; /* x position */ if(align==TLEFT || align==MLEFT || align==BLEFT || align==NONE) hot_x=-(float)item->max_width/2*style.magnify; else if(align==TCENTRE || align==MCENTRE || align==BCENTRE) hot_x=0; else hot_x=(float)item->max_width/2*style.magnify; /* pre-calculate sin and cos */ sin_angle=sin(angle); cos_angle=cos(angle); /* rotate hot_x and hot_y around bitmap centre */ hot_xp= hot_x*cos_angle - hot_y*sin_angle; hot_yp= hot_x*sin_angle + hot_y*cos_angle; /* text background will be drawn using XFillPolygon */ if(bg) { GC depth_one_gc; XPoint *xpoints; Pixmap empty_stipple; /* reserve space for XPoints */ xpoints=(XPoint *)malloc((unsigned)(4*item->nl*sizeof(XPoint))); if(!xpoints) return 1; /* rotate corner positions */ for(i=0; i<4*item->nl; i++) { xpoints[i].x=(float)x + ( (item->corners_x[i]-hot_x)*cos_angle + (item->corners_y[i]+hot_y)*sin_angle); xpoints[i].y=(float)y + (-(item->corners_x[i]-hot_x)*sin_angle + (item->corners_y[i]+hot_y)*cos_angle); } /* we want to swap foreground and background colors here; XGetGCValues() is only available in R4+ */ empty_stipple=XCreatePixmap(dpy, drawable, 1, 1, 1); depth_one_gc=XCreateGC(dpy, empty_stipple, 0, 0); XSetForeground(dpy, depth_one_gc, 0); XFillRectangle(dpy, empty_stipple, depth_one_gc, 0, 0, 2, 2); XSetStipple(dpy, my_gc, empty_stipple); XSetFillStyle(dpy, my_gc, FillOpaqueStippled); XFillPolygon(dpy, drawable, my_gc, xpoints, 4*item->nl, Nonconvex, CoordModeOrigin); /* free our resources */ free((char *)xpoints); XFreeGC(dpy, depth_one_gc); XFreePixmap(dpy, empty_stipple); } /* where should top left corner of bitmap go ? */ xp=(float)x-((float)item->cols_out/2 +hot_xp); yp=(float)y-((float)item->rows_out/2 -hot_yp); /* by default we draw the rotated bitmap, solid */ bitmap_to_paint=item->bitmap; /* handle user stippling */ #ifndef X11R3 { GC depth_one_gc; XGCValues values; Pixmap new_bitmap, inverse; /* try and get some GC properties */ if(XGetGCValues(dpy, gc, GCStipple|GCFillStyle|GCForeground|GCBackground| GCTileStipXOrigin|GCTileStipYOrigin, &values)) { /* only do this if stippling requested */ if((values.fill_style==FillStippled || values.fill_style==FillOpaqueStippled) && !bg) { /* opaque stipple: draw rotated text in background colour */ if(values.fill_style==FillOpaqueStippled) { XSetForeground(dpy, my_gc, values.background); XSetFillStyle(dpy, my_gc, FillStippled); XSetStipple(dpy, my_gc, item->bitmap); XSetTSOrigin(dpy, my_gc, xp, yp); XFillRectangle(dpy, drawable, my_gc, xp, yp, item->cols_out, item->rows_out); XSetForeground(dpy, my_gc, values.foreground); } /* this will merge the rotated text and the user's stipple */ new_bitmap=XCreatePixmap(dpy, drawable, item->cols_out, item->rows_out, 1); /* create a GC */ depth_one_gc=XCreateGC(dpy, new_bitmap, 0, 0); XSetForeground(dpy, depth_one_gc, 1); XSetBackground(dpy, depth_one_gc, 0); /* set the relative stipple origin */ XSetTSOrigin(dpy, depth_one_gc, values.ts_x_origin-xp, values.ts_y_origin-yp); /* fill the whole bitmap with the user's stipple */ XSetStipple(dpy, depth_one_gc, values.stipple); XSetFillStyle(dpy, depth_one_gc, FillOpaqueStippled); XFillRectangle(dpy, new_bitmap, depth_one_gc, 0, 0, item->cols_out, item->rows_out); /* set stipple origin back to normal */ XSetTSOrigin(dpy, depth_one_gc, 0, 0); /* this will contain an inverse copy of the rotated text */ inverse=XCreatePixmap(dpy, drawable, item->cols_out, item->rows_out, 1); /* invert text */ XSetFillStyle(dpy, depth_one_gc, FillSolid); XSetFunction(dpy, depth_one_gc, GXcopyInverted); XCopyArea(dpy, item->bitmap, inverse, depth_one_gc, 0, 0, item->cols_out, item->rows_out, 0, 0); /* now delete user's stipple everywhere EXCEPT on text */ XSetForeground(dpy, depth_one_gc, 0); XSetBackground(dpy, depth_one_gc, 1); XSetStipple(dpy, depth_one_gc, inverse); XSetFillStyle(dpy, depth_one_gc, FillStippled); XSetFunction(dpy, depth_one_gc, GXcopy); XFillRectangle(dpy, new_bitmap, depth_one_gc, 0, 0, item->cols_out, item->rows_out); /* free resources */ XFreePixmap(dpy, inverse); XFreeGC(dpy, depth_one_gc); /* this is the new bitmap */ bitmap_to_paint=new_bitmap; } } } #endif /*X11R3*/ /* paint text using stipple technique */ XSetFillStyle(dpy, my_gc, FillStippled); XSetStipple(dpy, my_gc, bitmap_to_paint); XSetTSOrigin(dpy, my_gc, xp, yp); XFillRectangle(dpy, drawable, my_gc, xp, yp, item->cols_out, item->rows_out); /* free our resources */ XFreeGC(dpy, my_gc); /* stippled bitmap no longer needed */ if(bitmap_to_paint!=item->bitmap) XFreePixmap(dpy, bitmap_to_paint); #ifdef CACHE_XIMAGES XFreePixmap(dpy, item->bitmap); #endif /*CACHE_XIMAGES*/ /* if item isn't cached, destroy it completely */ if(!item->cached) XRotFreeTextItem(dpy,item); /* we got to the end OK! */ return 0; }
void appRulerAllocateDrawingData( RulerData * rd, int vertical, int fontHeight, double magnification, APP_WIDGET w ) { AppDrawingData * add= &(rd->rdDrawingData); char name[128]; rd->rdFontHeight= fontHeight; if ( appSetDrawingDataForWidget( w, magnification, add ) ) { LDEB(1); } appDrawSetLineAttributes( add, 1, LINEstyleSOLID, LINEcapPROJECTING, LINEjoinMITER, (const unsigned char *)0, 0 ); if ( rd->rdFontName ) { sprintf( name, rd->rdFontName, fontHeight ); rd->rdFontStruct= appDrawOpenFont( add, name ); } else{ strcpy( name, "(None)" ); } if ( ! rd->rdFontStruct ) { SXDEB(name,rd->rdFontStruct); sprintf( name, "-*-*-medium-r-*-*-%d-*-*-*-m-*-iso8859-*", fontHeight ); rd->rdFontStruct= appDrawOpenFont( add, name ); } if ( vertical && rd->rdFontStruct && appOpenVerticalXFont( &(rd->rdVerticalFont), add, name, -1, &(add->addBackColor) ) ) { SDEB(name); } if ( rd->rdFontStruct ) { appDrawSetFont( add, rd->rdFontStruct ); } else{ SXDEB(name,rd->rdFontStruct); } # ifdef USE_MOTIF if ( DefaultDepth( add->addDisplay, add->addScreen ) <= 2 ) { int i; for ( i= 0; i < 16; i++ ) { memset( name+ 8* i+ 0, 0xaa, 4 ); memset( name+ 8* i+ 4, 0x55, 4 ); } rd->rdBackStipple= XCreateBitmapFromData( add->addDisplay, add->addDrawable, name, 32, 32 ); if ( ! rd->rdBackStipple ) { XDEB(rd->rdBackStipple); } appDrawBlackColor( add, &(add->addBackColor) ); XSetStipple( add->addDisplay, add->addGc, rd->rdBackStipple ); } # endif rd->rdDrawingDataAllocated= 1; return; }
void xf_gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index) { int i, j; int x, y; int w, h; Pixmap bmp; Pixmap* bmps; uint32 fgcolor; uint32 bgcolor; GLYPH_DATA* glyph; GLYPH_DATA** glyphs; GLYPH_FRAGMENT* fragment; xfInfo* xfi = GET_XFI(update); fgcolor = freerdp_color_convert(fast_index->foreColor, xfi->srcBpp, 32, xfi->clrconv); bgcolor = freerdp_color_convert(fast_index->backColor, xfi->srcBpp, 32, xfi->clrconv); XSetFunction(xfi->display, xfi->gc, GXcopy); XSetForeground(xfi->display, xfi->gc, bgcolor); XSetBackground(xfi->display, xfi->gc, fgcolor); if (fast_index->opaqueRect) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); x = fast_index->opLeft; y = fast_index->opTop; w = fast_index->opRight - fast_index->opLeft + 1; h = fast_index->opBottom - fast_index->opTop + 1; XFillRectangle(xfi->display, xfi->drawing, xfi->gc, x, y, w, h); if (xfi->drawing == xfi->primary) { if (xfi->remote_app != True) { XFillRectangle(xfi->display, xfi->drawable, xfi->gc, x, y, w, h); } gdi_InvalidateRegion(xfi->hdc, x, y, w, h); } } x = fast_index->bkLeft; y = fast_index->y; XSetFillStyle(xfi->display, xfi->gc, FillStippled); for (i = 0; i < fast_index->nfragments; i++) { fragment = &fast_index->fragments[i]; if (fragment->operation == GLYPH_FRAGMENT_USE) { fragment->indices = (GLYPH_FRAGMENT_INDEX*) glyph_fragment_get(xfi->cache->glyph, fragment->index, &fragment->nindices, (void**) &bmps); glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices); for (j = 0; j < fragment->nindices; j++) { glyphs[j] = glyph_get(xfi->cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]); } } else { bmps = (Pixmap*) xmalloc(sizeof(Pixmap*) * fragment->nindices); glyphs = (GLYPH_DATA**) xmalloc(sizeof(GLYPH_DATA*) * fragment->nindices); for (j = 0; j < fragment->nindices; j++) { glyphs[j] = glyph_get(xfi->cache->glyph, fast_index->cacheId, fragment->indices[j].index, (void**) &bmps[j]); } } for (j = 0; j < fragment->nindices; j++) { bmp = bmps[j]; glyph = glyphs[j]; XSetStipple(xfi->display, xfi->gc, bmp); XSetTSOrigin(xfi->display, xfi->gc, glyph->x + x, glyph->y + y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, glyph->x + x, glyph->y + y, glyph->cx, glyph->cy); XSetStipple(xfi->display, xfi->gc, xfi->bitmap_mono); if ((j + 1) < fragment->nindices) { if (!(fast_index->flAccel & SO_CHAR_INC_EQUAL_BM_BASE)) { if (fast_index->flAccel & SO_VERTICAL) { y += fragment->indices[j + 1].delta; } else { x += fragment->indices[j + 1].delta; } } else { x += glyph->cx; } } } if (fragment->operation == GLYPH_FRAGMENT_ADD) { glyph_fragment_put(xfi->cache->glyph, fragment->index, fragment->nindices, (void*) fragment->indices, (void*) bmps); } } if (xfi->drawing == xfi->primary) { if (xfi->remote_app != True) { XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, fast_index->bkLeft, fast_index->bkTop, fast_index->bkRight - fast_index->bkLeft + 1, fast_index->bkBottom - fast_index->bkTop + 1, fast_index->bkLeft, fast_index->bkTop); } gdi_InvalidateRegion(xfi->hdc, fast_index->bkLeft, fast_index->bkTop, fast_index->bkRight - fast_index->bkLeft + 1, fast_index->bkBottom - fast_index->bkTop + 1); } }
void xf_gdi_patblt(rdpUpdate* update, PATBLT_ORDER* patblt) { BRUSH* brush; Pixmap pattern; uint32 foreColor; uint32 backColor; xfInfo* xfi = GET_XFI(update); brush = &patblt->brush; xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_color_convert(patblt->foreColor, xfi->srcBpp, 32, xfi->clrconv); backColor = freerdp_color_convert(patblt->backColor, xfi->srcBpp, 32, xfi->clrconv); if (brush->style & CACHED_BRUSH) { brush->data = brush_get(xfi->cache->brush, brush->index, &brush->bpp); brush->style = GDI_BS_PATTERN; } if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, patblt->foreColor); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfi->display, xfi->gc, xfi->primary); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetStipple(xfi->display, xfi->gc_mono, pattern); } } else { printf("unimplemented brush style:%d\n", brush->style); } if (xfi->drawing == xfi->primary) { XSetFunction(xfi->display, xfi->gc, GXcopy); if (xfi->remote_app != True) { XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect); } gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } }
int main(int argc, char **argv) { Widget toplevel, rc, one; XtAppContext app; XtSetLanguageProc(NULL, NULL, NULL); toplevel = XtVaAppInitialize(&app, "BubbleButtonTest", NULL, 0, &argc, argv, NULL, NULL); rc = XmCreateRowColumn(toplevel, "RC", NULL, 0); one = XltCreateBubbleButton(rc, "BubbleButton1", NULL, 0); XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL); { XmString string; string = XmStringCreateSimple("MouseOver"); XtVaSetValues(one, XmNalignment, XmALIGNMENT_CENTER, XltNmouseOverString, string, NULL); XmStringFree(string); } XtManageChild(one); one = XltCreateBubbleButton(rc, "BubbleButton2", NULL, 0); { Pixmap pixmap; Pixmap pixmap_insens; XpmAttributes attrib; GC gc; { XpmColorSymbol colors[1]; XtVaGetValues(one, XmNbackground, &colors[0].pixel, NULL); colors[0].name = NULL; colors[0].value = "None"; attrib.valuemask = XpmCloseness | XpmColorSymbols; attrib.closeness = 40000; attrib.colorsymbols = colors; attrib.numsymbols = 1; XpmCreatePixmapFromData(XtDisplay(one), XRootWindowOfScreen(XtScreen(one)), dates, &pixmap, NULL, &attrib); pixmap_insens = XCreatePixmap(XtDisplay(one), pixmap, attrib.width, attrib.height, DefaultDepthOfScreen(XtScreen(one))); gc = XDefaultGCOfScreen(XtScreen(one)); XSetFunction(XtDisplay(one),gc,GXcopy); XCopyArea(XtDisplay(one), pixmap, pixmap_insens, gc, 0, 0, attrib.width, attrib.height, 0, 0); XSetFillStyle(XtDisplay(one), gc, FillStippled); XSetStipple(XtDisplay(one), gc, XmGetPixmapByDepth(XtScreen(one), "25_foreground", 1 /*WhitePixelOfScreen(XtScreen(ToolBar))*/, 0 /*BlackPixelOfScreen(XtScreen(ToolBar))*/, 1)); XFillRectangle(XtDisplay(one), pixmap_insens, gc, 0, 0, attrib.width + 1, attrib.height + 1); XpmFreeAttributes(&attrib); XtVaSetValues(one, XmNalignment, XmALIGNMENT_CENTER, XmNlabelType, XmPIXMAP, XmNlabelPixmap, pixmap, XltNmouseOverPixmap, pixmap_insens, NULL); } } XtAddCallback(one, XmNactivateCallback, (XtCallbackProc)Callback, NULL); XtManageChild(one); XtManageChild(rc); XtRealizeWidget(toplevel); XtAppMainLoop(app); exit(0); }
void xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) { rdpBrush* brush; xfBitmap* bitmap; UINT32 foreColor; UINT32 backColor; Pixmap pattern = 0; xfContext* context_ = (xfContext*) context; xfInfo* xfi = context_->xfi; brush = &mem3blt->brush; bitmap = (xfBitmap*) mem3blt->bitmap; xf_set_rop3(xfi, gdi_rop3_code(mem3blt->bRop)); foreColor = freerdp_color_convert_rgb(mem3blt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); backColor = freerdp_color_convert_rgb(mem3blt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); } } else if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); } else { printf("Mem3Blt unimplemented brush style:%d\n", brush->style); } XCopyArea(xfi->display, bitmap->pixmap, xfi->drawing, xfi->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); if (xfi->drawing == xfi->primary) { if (xfi->remote_app != TRUE) { XCopyArea(xfi->display, bitmap->pixmap, xfi->drawable, xfi->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); } gdi_InvalidateRegion(xfi->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight); } XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetTSOrigin(xfi->display, xfi->gc, 0, 0); if (pattern != 0) XFreePixmap(xfi->display, pattern); XSetFunction(xfi->display, xfi->gc, GXcopy); }
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { Pixmap pattern; rdpBrush* brush; UINT32 foreColor; UINT32 backColor; xfContext* context_ = (xfContext*) context; xfInfo* xfi = context_->xfi; xf_lock_x11(xfi, FALSE); brush = &patblt->brush; xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_color_convert_var(patblt->foreColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); backColor = freerdp_color_convert_var(patblt->backColor, context_->settings->ColorDepth, xfi->bpp, xfi->clrconv); if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, foreColor); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_HATCHED) { pattern = xf_mono_bitmap_new(xfi, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfi->display, pattern); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfi->display, xfi->gc, xfi->primary); XFreePixmap(xfi->display, pattern); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, xfi->drawing, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfi->display, pattern); } } else { fprintf(stderr, "unimplemented brush style:%d\n", brush->style); } if (xfi->drawing == xfi->primary) { gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } XSetFunction(xfi->display, xfi->gc, GXcopy); xf_unlock_x11(xfi, FALSE); }
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { Drawable dst; Pixmap pattern; rdpBrush* brush; uint32 foreColor; uint32 backColor; xfInfo* xfi = ((xfContext*) context)->xfi; GET_DST(xfi, dst); brush = &patblt->brush; xf_set_rop3(xfi, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_color_convert_rgb(patblt->foreColor, xfi->srcBpp, 32, xfi->clrconv); backColor = freerdp_color_convert_rgb(patblt->backColor, xfi->srcBpp, 32, xfi->clrconv); if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetForeground(xfi->display, xfi->gc, foreColor); XFillRectangle(xfi->display, dst, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, dst, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfi->display, xfi->gc, xfi->primary); XFreePixmap(xfi->display, pattern); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, foreColor); XSetBackground(xfi->display, xfi->gc, backColor); XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillRectangle(xfi->display, dst, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfi->display, pattern); } } else { printf("unimplemented brush style:%d\n", brush->style); } if (xfi->drawing == xfi->primary) { XSetFunction(xfi->display, xfi->gc, GXcopy); if (!xfi->remote_app && !xfi->skip_bs) { XCopyArea(xfi->display, xfi->primary, xfi->drawable, xfi->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect); } gdi_InvalidateRegion(xfi->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } XSetFunction(xfi->display, xfi->gc, GXcopy); }
static BOOL xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) { int i, npoints; XPoint* points; Pixmap pattern; const rdpBrush* brush; XColor foreColor; XColor backColor; xfContext* xfc = (xfContext*) context; BOOL ret = TRUE; if (!xf_decode_color(xfc, polygon_cb->foreColor, &foreColor)) return FALSE; if (!xf_decode_color(xfc, polygon_cb->backColor, &backColor)) return FALSE; xf_lock_x11(xfc, FALSE); brush = &(polygon_cb->brush); xf_set_rop2(xfc, polygon_cb->bRop2); npoints = polygon_cb->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); if (!points) { xf_unlock_x11(xfc, FALSE); return FALSE; } points[0].x = polygon_cb->xStart; points[0].y = polygon_cb->yStart; for (i = 0; i < polygon_cb->numPoints; i++) { points[i + 1].x = polygon_cb->points[i].x; points[i + 1].y = polygon_cb->points[i].y; } switch (polygon_cb->fillMode) { case GDI_FILL_ALTERNATE: /* alternate */ XSetFillRule(xfc->display, xfc->gc, EvenOddRule); break; case GDI_FILL_WINDING: /* winding */ XSetFillRule(xfc->display, xfc->gc, WindingRule); break; default: WLog_ERR(TAG, "PolygonCB unknown fillMode: %"PRIu32"", polygon_cb->fillMode); break; } if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); } else { pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetForeground(xfc->display, xfc->gc, backColor.pixel); XSetBackground(xfc->display, xfc->gc, foreColor.pixel); if (polygon_cb->backMode == BACKMODE_TRANSPARENT) XSetFillStyle(xfc->display, xfc->gc, FillStippled); else if (polygon_cb->backMode == BACKMODE_OPAQUE) XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); } XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillPolygon(xfc->display, xfc->drawing, xfc->gc, points, npoints, Complex, CoordModePrevious); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetTSOrigin(xfc->display, xfc->gc, 0, 0); XFreePixmap(xfc->display, pattern); if (xfc->drawing == xfc->primary) { if (!xf_gdi_invalidate_poly_region(xfc, points, npoints)) ret = FALSE; } } else { WLog_ERR(TAG, "PolygonCB unimplemented brush style:%"PRIu32"", brush->style); } XSetFunction(xfc->display, xfc->gc, GXcopy); free(points); xf_unlock_x11(xfc, FALSE); return ret; }
static BOOL xf_gdi_mem3blt(rdpContext* context, MEM3BLT_ORDER* mem3blt) { const rdpBrush* brush; xfBitmap* bitmap; XColor foreColor; XColor backColor; Pixmap pattern = 0; xfContext* xfc = (xfContext*) context; BOOL ret = FALSE; if (!xfc->display || !xfc->drawing) return FALSE; if (!xf_decode_color(xfc, mem3blt->foreColor, &foreColor)) return FALSE; if (!xf_decode_color(xfc, mem3blt->backColor, &backColor)) return FALSE; xf_lock_x11(xfc, FALSE); brush = &mem3blt->brush; bitmap = (xfBitmap*) mem3blt->bitmap; if (!xf_set_rop3(xfc, gdi_rop3_code(mem3blt->bRop))) goto fail; switch (brush->style) { case GDI_BS_PATTERN: if (brush->bpp > 1) { pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } else { pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetBackground(xfc->display, xfc->gc, backColor.pixel); XSetForeground(xfc->display, xfc->gc, foreColor.pixel); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); } break; case GDI_BS_SOLID: XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetBackground(xfc->display, xfc->gc, backColor.pixel); XSetForeground(xfc->display, xfc->gc, foreColor.pixel); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); break; default: WLog_ERR(TAG, "Mem3Blt unimplemented brush style:%"PRIu32"", brush->style); goto fail; } XCopyArea(xfc->display, bitmap->pixmap, xfc->drawing, xfc->gc, mem3blt->nXSrc, mem3blt->nYSrc, mem3blt->nWidth, mem3blt->nHeight, mem3blt->nLeftRect, mem3blt->nTopRect); ret = TRUE; if (xfc->drawing == xfc->primary) ret = gdi_InvalidateRegion(xfc->hdc, mem3blt->nLeftRect, mem3blt->nTopRect, mem3blt->nWidth, mem3blt->nHeight); XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetTSOrigin(xfc->display, xfc->gc, 0, 0); if (pattern != 0) XFreePixmap(xfc->display, pattern); fail: XSetFunction(xfc->display, xfc->gc, GXcopy); xf_unlock_x11(xfc, FALSE); return ret; }
void xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { Pixmap pattern; rdpBrush* brush; UINT32 foreColor; UINT32 backColor; xfContext* xfc = (xfContext*) context; xf_lock_x11(xfc, FALSE); brush = &patblt->brush; xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop)); foreColor = freerdp_convert_gdi_order_color(patblt->foreColor, context->settings->ColorDepth, xfc->format, xfc->palette); foreColor = xf_gdi_get_color(xfc, foreColor); backColor = freerdp_convert_gdi_order_color(patblt->backColor, context->settings->ColorDepth, xfc->format, xfc->palette); backColor = xf_gdi_get_color(xfc, backColor); if (brush->style == GDI_BS_SOLID) { XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetForeground(xfc->display, xfc->gc, foreColor); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } else if (brush->style == GDI_BS_HATCHED) { pattern = xf_mono_bitmap_new(xfc, 8, 8, GDI_BS_HATCHED_PATTERNS + 8 * brush->hatch); XSetForeground(xfc->display, xfc->gc, backColor); XSetBackground(xfc->display, xfc->gc, foreColor); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } else if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfc->display, xfc->gc, xfc->primary); XFreePixmap(xfc->display, pattern); } else { pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetForeground(xfc->display, xfc->gc, backColor); XSetBackground(xfc->display, xfc->gc, foreColor); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } } else { WLog_ERR(TAG, "unimplemented brush style:%d", brush->style); } if (xfc->drawing == xfc->primary) { XSetFunction(xfc->display, xfc->gc, GXcopy); if (!xfc->remote_app) { XCopyArea(xfc->display, xfc->primary, xfc->drawable, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight, patblt->nLeftRect, patblt->nTopRect); } gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); } XSetFunction(xfc->display, xfc->gc, GXcopy); xf_unlock_x11(xfc, FALSE); }
static void setbrushstyle (wmfAPI* API,wmfDC* dc) { wmf_x_t* ddata = WMF_X_GetData (API); wmfBMP* bmp = 0; wmfRGB pixel; wmfBrush* brush = 0; int opacity; int fill_style; U16 i; U16 j; XGCValues values; brush = WMF_DC_BRUSH (dc); values.function = Our_XROPfunction[WMF_DC_ROP (dc) - 1]; if (values.function == GXinvert) { values.function = GXxor; values.foreground = ddata->black; } else { values.foreground = get_color (API,WMF_BRUSH_COLOR (brush)); } values.background = get_color (API,WMF_DC_BACKGROUND (dc)); switch (WMF_BRUSH_STYLE (brush)) { /* TODO: these arrays are convenient but how SEG-safe are they? */ case BS_HATCHED: if (ddata->hatch != None) XFreePixmap (ddata->display,ddata->hatch); ddata->hatch = XCreateBitmapFromData (ddata->display,ddata->root, HatchBrushes[WMF_BRUSH_HATCH (brush)],8,8); fill_style = ((WMF_DC_OPAQUE (dc)) ? FillOpaqueStippled : FillStippled); XSetStipple (ddata->display,ddata->gc,ddata->hatch); break; case BS_DIBPATTERN: setdefaultstyle (API); bmp = WMF_BRUSH_BITMAP (brush); if (ddata->brush != None) { XFreePixmap (ddata->display,ddata->brush); ddata->brush = None; } if (bmp->data == 0) { fill_style = FillSolid; break; } ddata->brush = XCreatePixmap (ddata->display,ddata->root, bmp->width,bmp->height,ddata->depth); if (ddata->brush == None) { fill_style = FillSolid; break; } for (j = 0; j < bmp->height; j++) { for (i = 0; i < bmp->width; i++) { opacity = wmf_ipa_bmp_color (API,bmp,&pixel,i,j); XSetForeground (ddata->display,ddata->gc,get_color (API,&pixel)); XDrawPoint (ddata->display,ddata->brush,ddata->gc,i,j); } } XSetTile (ddata->display,ddata->gc,ddata->brush); fill_style = FillTiled; break; case BS_NULL: case BS_SOLID: case BS_PATTERN: default: fill_style = FillSolid; break; } XSetFillStyle (ddata->display,ddata->gc,fill_style); switch (WMF_DC_POLYFILL (dc)) { case ALTERNATE: values.fill_rule = EvenOddRule; break; case WINDING: values.fill_rule = WindingRule; break; default: values.fill_rule = EvenOddRule; break; } XChangeGC (ddata->display,ddata->gc,GCFunction|GCForeground|GCBackground|GCFillRule,&values); }
void xf_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) { int i, npoints; XPoint* points; Pixmap pattern; rdpBrush* brush; UINT32 foreColor; UINT32 backColor; xfInfo* xfi = ((xfContext*) context)->xfi; brush = &(polygon_cb->brush); xf_set_rop2(xfi, polygon_cb->bRop2); foreColor = freerdp_color_convert_rgb(polygon_cb->foreColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); backColor = freerdp_color_convert_rgb(polygon_cb->backColor, ((xfContext*) context)->settings->ColorDepth, xfi->bpp, xfi->clrconv); npoints = polygon_cb->numPoints + 1; points = malloc(sizeof(XPoint) * npoints); points[0].x = polygon_cb->xStart; points[0].y = polygon_cb->yStart; for (i = 0; i < polygon_cb->numPoints; i++) { points[i + 1].x = polygon_cb->points[i].x; points[i + 1].y = polygon_cb->points[i].y; } switch (polygon_cb->fillMode) { case 1: /* alternate */ XSetFillRule(xfi->display, xfi->gc, EvenOddRule); break; case 2: /* winding */ XSetFillRule(xfi->display, xfi->gc, WindingRule); break; default: printf("PolygonCB unknown fillMode: %d\n", polygon_cb->fillMode); break; } if (brush->style == GDI_BS_PATTERN) { if (brush->bpp > 1) { pattern = xf_brush_new(xfi, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfi->display, xfi->gc, FillTiled); XSetTile(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillPolygon(xfi->display, xfi->drawing, xfi->gc, points, npoints, Complex, CoordModePrevious); if (xfi->drawing == xfi->primary) { XFillPolygon(xfi->display, xfi->drawable, xfi->gc, points, npoints, Complex, CoordModePrevious); } XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetTSOrigin(xfi->display, xfi->gc, 0, 0); XFreePixmap(xfi->display, pattern); } else { pattern = xf_mono_bitmap_new(xfi, 8, 8, brush->data); XSetForeground(xfi->display, xfi->gc, backColor); XSetBackground(xfi->display, xfi->gc, foreColor); if (polygon_cb->backMode == BACKMODE_TRANSPARENT) XSetFillStyle(xfi->display, xfi->gc, FillStippled); else if (polygon_cb->backMode == BACKMODE_OPAQUE) XSetFillStyle(xfi->display, xfi->gc, FillOpaqueStippled); XSetStipple(xfi->display, xfi->gc, pattern); XSetTSOrigin(xfi->display, xfi->gc, brush->x, brush->y); XFillPolygon(xfi->display, xfi->drawing, xfi->gc, points, npoints, Complex, CoordModePrevious); if (xfi->drawing == xfi->primary) { XFillPolygon(xfi->display, xfi->drawable, xfi->gc, points, npoints, Complex, CoordModePrevious); } XSetFillStyle(xfi->display, xfi->gc, FillSolid); XSetTSOrigin(xfi->display, xfi->gc, 0, 0); XFreePixmap(xfi->display, pattern); } } else { printf("PolygonCB unimplemented brush style:%d\n", brush->style); } XSetFunction(xfi->display, xfi->gc, GXcopy); free(points); }
void WSetStipple(unsigned int Index) { XSetStipple (prDisplay, prGC, prPixmap[Index]); }
static void setupGC(Display * dpy, GC gc, unsigned long valuemask, XGCValues * values) { if (valuemask & GCFunction) XSetFunction(dpy, gc, values->function); if (valuemask & GCForeground) XSetForeground(dpy, gc, values->foreground); if (valuemask & GCBackground) XSetBackground(dpy, gc, values->background); //FIXME add save gc->ext_data values for each of these... if (valuemask & GCFont) XSetFont(dpy, gc, values->font); if (valuemask & GCGraphicsExposures) XSetGraphicsExposures(dpy, gc, values->graphics_exposures); if ((valuemask & GCClipXOrigin) && (valuemask & GCClipYOrigin)) XSetClipOrigin(dpy, gc, values->clip_x_origin, values->clip_y_origin); if (valuemask & GCClipMask) XSetClipMask(dpy, gc, values->clip_mask); if (valuemask & GCFillStyle) XSetFillStyle(dpy, gc, values->fill_style); if ((valuemask & GCTileStipXOrigin) && (valuemask & GCTileStipYOrigin)) XSetTSOrigin(dpy, gc, values->ts_x_origin, values->ts_y_origin); // FIXME if (valuemask & (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle)) XSetLineAttributes(dpy, gc, values->line_width, values->line_style, values->cap_style, values->join_style); if (valuemask & GCFillRule) XSetFillStyle(dpy, gc, values->fill_rule); if (valuemask & GCTile) XSetTile(dpy, gc, values->tile); if (valuemask & GCStipple) XSetStipple(dpy, gc, values->stipple); if (valuemask & (GCDashOffset | GCDashList)) { // FIXME is this correct for values->dashes? if (values->dashes) { char d[2]; d[0] = d[1] = values->dashes; XSetDashes(dpy, gc, values->dash_offset, d, 2); } } if (valuemask & GCSubwindowMode) XSetSubwindowMode(dpy, gc, values->subwindow_mode); if (valuemask & GCPlaneMask) DPRINTF("XCreateGC: GCPlaneMask not implemented\n"); if (valuemask & GCArcMode) DPRINTF("XCreateGC: GCArcMode not implemented\n"); }
static BOOL xf_gdi_patblt(rdpContext* context, PATBLT_ORDER* patblt) { const rdpBrush* brush; xfContext* xfc = (xfContext*) context; BOOL ret = FALSE; XColor xfg, xbg; if (!xf_decode_color(xfc, patblt->foreColor, &xfg)) return FALSE; if (!xf_decode_color(xfc, patblt->backColor, &xbg)) return FALSE; xf_lock_x11(xfc, FALSE); brush = &patblt->brush; if (!xf_set_rop3(xfc, gdi_rop3_code(patblt->bRop))) goto fail; switch (brush->style) { case GDI_BS_SOLID: XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetBackground(xfc->display, xfc->gc, xbg.pixel); XSetForeground(xfc->display, xfc->gc, xfg.pixel); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); break; case GDI_BS_HATCHED: { Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8, &GDI_BS_HATCHED_PATTERNS[8 * brush->hatch]); XSetBackground(xfc->display, xfc->gc, xbg.pixel); XSetForeground(xfc->display, xfc->gc, xfg.pixel); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } break; case GDI_BS_PATTERN: if (brush->bpp > 1) { Pixmap pattern = xf_brush_new(xfc, 8, 8, brush->bpp, brush->data); XSetFillStyle(xfc->display, xfc->gc, FillTiled); XSetTile(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XSetTile(xfc->display, xfc->gc, xfc->primary); XFreePixmap(xfc->display, pattern); } else { Pixmap pattern = xf_mono_bitmap_new(xfc, 8, 8, brush->data); XSetBackground(xfc->display, xfc->gc, xfg.pixel); XSetForeground(xfc->display, xfc->gc, xbg.pixel); XSetFillStyle(xfc->display, xfc->gc, FillOpaqueStippled); XSetStipple(xfc->display, xfc->gc, pattern); XSetTSOrigin(xfc->display, xfc->gc, brush->x, brush->y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); XFreePixmap(xfc->display, pattern); } break; default: WLog_ERR(TAG, "unimplemented brush style:%"PRIu32"", brush->style); goto fail; } ret = TRUE; if (xfc->drawing == xfc->primary) ret = gdi_InvalidateRegion(xfc->hdc, patblt->nLeftRect, patblt->nTopRect, patblt->nWidth, patblt->nHeight); fail: XSetFunction(xfc->display, xfc->gc, GXcopy); xf_unlock_x11(xfc, FALSE); return ret; }
void XmLStringDrawDirection(Display *dpy, Window win, XmFontList fontlist, XmString string, GC gc, int x, int y, Dimension width, unsigned char alignment, unsigned char layout_direction, unsigned char drawing_direction) { Screen *screen; XFontStruct *fontStruct; XImage *sourceImage, *destImage; Pixmap pixmap; GC pixmapGC; /* int sourceWidth, sourceHeight;*/ int destWidth, destHeight; int stringWidth, stringHeight; int i, j, bytesPerLine; Dimension dW, dH; char *data; screen = DefaultScreenOfDisplay(dpy); XmStringExtent(fontlist, string, &dW, &dH); stringWidth = (int)dW; stringHeight = (int)dH; if (!stringWidth || !stringHeight) return; /* draw string into 1 bit deep pixmap */ pixmap = XCreatePixmap(dpy, win, stringWidth, stringHeight, 1); pixmapGC = XCreateGC(dpy, pixmap, 0, NULL); fontStruct = XLoadQueryFont(dpy, "fixed"); if (!fontStruct) { fprintf(stderr, "XmLStringDrawDirection: error - "); fprintf(stderr, "can't load fixed font\n"); return; } XSetFont(dpy, pixmapGC, fontStruct->fid); XSetBackground(dpy, pixmapGC, 0L); XSetForeground(dpy, pixmapGC, 0L); XFillRectangle(dpy, pixmap, pixmapGC, 0, 0, stringWidth, stringHeight); XSetForeground(dpy, pixmapGC, 1L); XmStringDraw(dpy, pixmap, fontlist, string, pixmapGC, 0, 0, stringWidth, XmALIGNMENT_BEGINNING, layout_direction, 0); XFreeFont(dpy, fontStruct); /* copy 1 bit deep pixmap into source image */ sourceImage = XGetImage(dpy, pixmap, 0, 0, stringWidth, stringHeight, 1, XYPixmap); XFreePixmap(dpy, pixmap); /* draw rotated text into destination image */ if (drawing_direction == XmSTRING_UP || drawing_direction == XmSTRING_DOWN) { destWidth = stringHeight; destHeight = stringWidth; } else { destWidth = stringWidth; destHeight = stringHeight; } bytesPerLine = (destWidth - 1) / 8 + 1; data = (char *)malloc(bytesPerLine * destHeight); destImage = XCreateImage(dpy, DefaultVisualOfScreen(screen), 1, XYBitmap, 0, data, destWidth, destHeight, 8, 0); for (i = 0; i < stringWidth; i++) for (j = 0; j < stringHeight; j++) { if (drawing_direction == XmSTRING_UP) XPutPixel(destImage, j, i, XGetPixel(sourceImage, stringWidth - i - 1, j)); else if (drawing_direction == XmSTRING_DOWN) XPutPixel(destImage, stringHeight - j - 1, stringWidth - i - 1, XGetPixel(sourceImage, stringWidth - i - 1, j)); else if (drawing_direction == XmSTRING_LEFT) XPutPixel(destImage, i, stringHeight - j - 1, XGetPixel(sourceImage, stringWidth - i - 1, j)); else XPutPixel(destImage, i, j, XGetPixel(sourceImage, i, j)); } XDestroyImage(sourceImage); /* copy rotated image into 1 bit deep pixmap */ pixmap = XCreatePixmap(dpy, win, destWidth, destHeight, 1); XPutImage(dpy, pixmap, pixmapGC, destImage, 0, 0, 0, 0, destWidth, destHeight); XDestroyImage(destImage); XFreeGC(dpy, pixmapGC); /* adjust position for alignment */ if (drawing_direction == XmSTRING_UP || drawing_direction == XmSTRING_DOWN) { if (alignment == XmALIGNMENT_BEGINNING) ; else if (alignment == XmALIGNMENT_CENTER) y += width / 2 - stringWidth / 2; else if (alignment == XmALIGNMENT_END) y += (int)width - stringWidth; } else { if (alignment == XmALIGNMENT_BEGINNING) ; else if (alignment == XmALIGNMENT_CENTER) x += width / 2 - stringWidth / 2; else if (alignment == XmALIGNMENT_END) x += (int)width - stringWidth; } /* draw the pixmap as a stipple in the window */ XSetStipple(dpy, gc, pixmap); XSetFillStyle(dpy, gc, FillStippled); XSetTSOrigin(dpy, gc, x % destWidth, y % destHeight); XFillRectangle(dpy, win, gc, x, y, destWidth, destHeight); XFreePixmap(dpy, pixmap); XSetFillStyle(dpy, gc, FillSolid); }