void TStatusPanel_STD::update(Status_Pack * sp) { TIMC * imc = sp->imc; XClearWindow(TWinMan::get_display(), id()); uint16_t x = 2; uint16_t y = fontset->ascent() + 2; if (imc == NULL){ im_desc.copy(sp->im_desc[0]); #ifdef MDK_PATCH char dummy[10]; im_desc.tombs(dummy, 4); XmbDrawString(TWinMan::get_display(), id(), fontset->id(), gc->id(), x, y, dummy, strlen(dummy)); #else XwcDrawString(TWinMan::get_display(), id(), fontset->id(), gc->id(), x, y, &im_desc[0], 1); #endif return; } if (!imc->enabled()){ #ifdef MDK_PATCH XmbDrawImageString(TWinMan::get_display(), id(), fontset->id(), gc->id(), x, y, "En", 2); #else XwcDrawImageString(TWinMan::get_display(), id(), fontset->id(), gc->id(), x, y, L"En", 2); #endif return; } if (imc->is_mb_input()){ //XFillArc(display, stat_win, stat_gc, space_width, space_heigth, font_width * 2, font_height, 0, (360 * 64)); XFillRectangle(TWinMan::get_display(), id(), stat_gc->id(), 2, 2, fontset->width() * 2 + 1, fontset->height() + 1); }else{ XPoint p[3]; p[0].x = 2; p[0].y = 2; p[1].x = fontset->width() * 2 + 3; p[1].y = 2; p[2].x = 2; p[2].y = fontset->height() + 3; //XFillArc(display, stat_win, stat_gc, space_width, space_heigth, font_width * 2, font_height, (45 * 64), (225 * 64)); XFillPolygon(TWinMan::get_display(), id(), stat_gc->id(), p, 3, Convex,CoordModeOrigin); } im_desc.copy(sp->im_desc[0]); #ifdef MDK_PATCH char dummy[10]; im_desc.tombs(dummy, 4); XmbDrawString(TWinMan::get_display(), id(), fontset->id(), gc->id(), x, y, dummy, strlen(dummy)); #else XwcDrawString(TWinMan::get_display(), id(), fontset->id(), gc->id(), x, y, &im_desc[0], 1); #endif }
static void gdk_x11_draw_text_wc (GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const GdkWChar *text, gint text_length) { GdkDrawableImplX11 *impl; Display *xdisplay; impl = GDK_DRAWABLE_IMPL_X11 (drawable); xdisplay = GDK_SCREEN_XDISPLAY (impl->screen); if (font->type == GDK_FONT_FONT) { XFontStruct *xfont = (XFontStruct *) GDK_FONT_XFONT (font); gchar *text_8bit; gint i; XSetFont(xdisplay, GDK_GC_GET_XGC (gc), xfont->fid); text_8bit = g_new (gchar, text_length); for (i=0; i<text_length; i++) text_8bit[i] = text[i]; XDrawString (xdisplay, impl->xid, GDK_GC_GET_XGC (gc), x, y, text_8bit, text_length); g_free (text_8bit); } else if (font->type == GDK_FONT_FONTSET) { if (sizeof(GdkWChar) == sizeof(wchar_t)) { XwcDrawString (xdisplay, impl->xid, (XFontSet) GDK_FONT_XFONT (font), GDK_GC_GET_XGC (gc), x, y, (wchar_t *)text, text_length); } else { wchar_t *text_wchar; gint i; text_wchar = g_new (wchar_t, text_length); for (i=0; i<text_length; i++) text_wchar[i] = text[i]; XwcDrawString (xdisplay, impl->xid, (XFontSet) GDK_FONT_XFONT (font), GDK_GC_GET_XGC (gc), x, y, text_wchar, text_length); g_free (text_wchar); } } else
/* * Function: * PaintText * * Parameters: * w - text sink object * gc - gc to paint text * x - location to paint the text * y - "" * buf - buffer and length of text to paint * len - "" * clear_bg - clear background before drawing ? * * Description: * Actually paints the text into the window. * * Returns: * The width of the text painted */ static unsigned int PaintText(Widget w, GC gc, int x, int y, wchar_t *buf, int len, Bool clear_bg) { MultiSinkObject sink = (MultiSinkObject)w; TextWidget ctx = (TextWidget)XtParent(w); XFontSet fontset = sink->multi_sink.fontset; unsigned int width = XwcTextEscapement(fontset, buf, len); if (((int)width) <= -x) /* Don't draw if we can't see it */ return (width); if (clear_bg) { XFontSetExtents *ext = XExtentsOfFontSet(fontset); _XawTextSinkClearToBackground(w, x, y - abs(ext->max_logical_extent.y), width, ext->max_logical_extent.height); XwcDrawString(XtDisplay(ctx), XtWindow(ctx), fontset, gc, x, y, buf, len); } else XwcDrawImageString(XtDisplay(ctx), XtWindow(ctx), fontset, gc, x, y, buf, len); return (width); }
unsigned char *YsSystemFontCache::InternalData::RGBABitmap( unsigned int &wid,unsigned int &hei,unsigned int &dstBytePerLine, const wchar_t str[],unsigned int dstBitPerPixel, const unsigned char fgCol[3],const unsigned char bgCol[3], YSBOOL reverse) { if(NULL==str || 0==str[0] || (1!=dstBitPerPixel && 16!=dstBitPerPixel && 32!=dstBitPerPixel)) { wid=0; hei=0; return NULL; } if(NULL!=dsp && NULL!=fontSet) { wid=0; hei=0; int i=0,i0=0; for(;;) { if(0==str[i] || '\n'==str[i]) { XRectangle inkRect,logRect; const int ext=XwcTextExtents(fontSet,str+i0,i-i0,&inkRect,&logRect); if(wid<ext) { wid=ext; } hei+=logRect.height; i0=i+1; } if(0==str[i]) { break; } i++; } wid=((wid+3)/4*4); if(0>=wid || 0>=hei) { wid=0; hei=0; return NULL; } const int defDepth=DefaultDepth(dsp,0); Pixmap pixmap=XCreatePixmap(dsp,rootWin,wid,hei,defDepth); GC gc; if(NULL!=(gc=XCreateGC(dsp,pixmap,0,0))) { XSetForeground(dsp,gc,BlackPixel(dsp,0)); XFillRectangle(dsp,pixmap,gc,0,0,wid,hei); XSetForeground(dsp,gc,WhitePixel(dsp,0)); int y=0; i=0; i0=0; for(;;) { if(0==str[i] || '\n'==str[i]) { XRectangle inkRect,logRect; const int ext=XwcTextExtents(fontSet,str+i0,i-i0,&inkRect,&logRect); XwcDrawString(dsp,pixmap,fontSet,gc,0,y+logRect.height-1,str+i0,i-i0); y+=logRect.height; i0=i+1; } if(0==str[i]) { break; } i++; } unsigned char *retBuf=NULL; XImage *image=XGetImage(dsp,pixmap,0,0,wid,hei,~0,XYPixmap); if(NULL!=image) { switch(dstBitPerPixel) { case 1: dstBytePerLine=((wid+31)&~31)/8; break; case 16: case 32: dstBytePerLine=wid*dstBitPerPixel/8; break; } const size_t bufSize=dstBytePerLine*hei; retBuf=new unsigned char [bufSize]; if(1==dstBitPerPixel) { int i; for(i=0; i<bufSize; i++) { retBuf[i]=0; } } int x,y; unsigned char *dstLineTop=retBuf; for(y=0; y<image->height; y++) { const int yInImage=(YSTRUE!=reverse ? y : image->height-1-y); unsigned char srcMask=1; unsigned char *srcLineTop=(unsigned char *)image->data+yInImage*image->bytes_per_line; unsigned char dstMask=0x80; unsigned char *dstPtr=dstLineTop; for(x=0; x<image->width; x++) { const unsigned char *col; unsigned char alpha; if(0!=((*srcLineTop)&srcMask)) { col=fgCol; alpha=255; } else { col=bgCol; alpha=0; } switch(dstBitPerPixel) { case 1: if(255==alpha) { (*dstPtr)|=dstMask; } if(1==dstMask) { dstMask=0x80; dstPtr++; } else { dstMask>>=1; } break; case 16: dstLineTop[x*2 ]=col[0]; dstLineTop[x*2+1]=alpha; break; case 32: dstLineTop[x*4 ]=col[0]; dstLineTop[x*4+1]=col[1]; dstLineTop[x*4+2]=col[2]; dstLineTop[x*4+3]=alpha; break; } if(0x80==srcMask) { srcMask=1; srcLineTop++; } else { srcMask<<=1; } } for(x=x; x<wid; x++) { switch(dstBitPerPixel) { case 16: dstLineTop[x*2 ]=bgCol[0]; dstLineTop[x*2+1]=0; break; case 32: dstLineTop[x*4 ]=bgCol[0]; dstLineTop[x*4+1]=bgCol[1]; dstLineTop[x*4+2]=bgCol[2]; dstLineTop[x*4+3]=0; break; } } dstLineTop+=dstBytePerLine; } } XFreeGC(dsp,gc); XFreePixmap(dsp,pixmap); return retBuf; }