X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frendercontrol.cc;h=0f84af892b22b2dc68c75f6d7df385056687229b;hb=d8d9b42777ace234f3471918e1210062578f8188;hp=479de3d91c09c4bffd697cd5a9522d2b97420651;hpb=02066c5d0b09ae49aa1f9b7193fb16f1ac7f6a37;p=chaz%2Fopenbox diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index 479de3d9..0f84af89 100644 --- a/otk/rendercontrol.cc +++ b/otk/rendercontrol.cc @@ -9,6 +9,10 @@ #include "rendertexture.hh" #include "display.hh" #include "screeninfo.hh" +#include "surface.hh" +#include "color.hh" +#include "font.hh" +#include "ustring.hh" extern "C" { #ifdef HAVE_STDLIB_H @@ -23,19 +27,17 @@ namespace otk { RenderControl *RenderControl::getRenderControl(int screen) { - const ScreenInfo *info = display->screenInfo(screen); - // get the visual on the screen and return the correct type of RenderControl - int vclass = info->visual()->c_class; + int vclass = display->screenInfo(screen)->visual()->c_class; switch (vclass) { case TrueColor: - return new TrueRenderControl(info); + return new TrueRenderControl(screen); case PseudoColor: case StaticColor: -// return new PseudoRenderControl(info); +// return new PseudoRenderControl(screen); case GrayScale: case StaticGray: -// return new GrayRenderControl(info); +// return new GrayRenderControl(screen); default: printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"), vclass); @@ -43,7 +45,7 @@ RenderControl *RenderControl::getRenderControl(int screen) } } -RenderControl::RenderControl(const ScreenInfo *screen) +RenderControl::RenderControl(int screen) : _screen(screen) { printf("Initializing RenderControl\n"); @@ -58,4 +60,46 @@ RenderControl::~RenderControl() } +void RenderControl::drawString(Surface& sf, const Font &font, int x, int y, + const Color &color, const ustring &string) const +{ + assert(sf._screen == _screen); + XftDraw *d = sf._xftdraw; + assert(d); // this means that the background hasn't been rendered yet! + + if (font._shadow) { + XftColor c; + c.color.red = 0; + c.color.green = 0; + c.color.blue = 0; + c.color.alpha = font._tint | font._tint << 8; // transparent shadow + c.pixel = BlackPixel(**display, _screen); + + if (string.utf8()) + XftDrawStringUtf8(d, &c, font._xftfont, x + font._offset, + font._xftfont->ascent + y + font._offset, + (FcChar8*)string.c_str(), string.bytes()); + else + XftDrawString8(d, &c, font._xftfont, x + font._offset, + font._xftfont->ascent + y + font._offset, + (FcChar8*)string.c_str(), string.bytes()); + } + + XftColor c; + c.color.red = color.red() | color.red() << 8; + c.color.green = color.green() | color.green() << 8; + c.color.blue = color.blue() | color.blue() << 8; + c.pixel = color.pixel(); + c.color.alpha = 0xff | 0xff << 8; // no transparency in Color yet + + if (string.utf8()) + XftDrawStringUtf8(d, &c, font._xftfont, x, font._xftfont->ascent + y, + (FcChar8*)string.c_str(), string.bytes()); + else + XftDrawString8(d, &c, font._xftfont, x, font._xftfont->ascent + y, + (FcChar8*)string.c_str(), string.bytes()); + + return; +} + }