X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frendercontrol.cc;h=0f84af892b22b2dc68c75f6d7df385056687229b;hb=0348a2f3abd2334f5f5812c5fb45c1b4fffb46a5;hp=1dd5704df54a14b8797e446dd7c4ec84ca4be7a9;hpb=24b33ef877808f0af5b967f21c011ab8b314e780;p=chaz%2Fopenbox diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index 1dd5704d..0f84af89 100644 --- a/otk/rendercontrol.cc +++ b/otk/rendercontrol.cc @@ -6,8 +6,13 @@ #include "rendercontrol.hh" #include "truerendercontrol.hh" +#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 @@ -22,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); @@ -42,7 +45,7 @@ RenderControl *RenderControl::getRenderControl(int screen) } } -RenderControl::RenderControl(const ScreenInfo *screen) +RenderControl::RenderControl(int screen) : _screen(screen) { printf("Initializing RenderControl\n"); @@ -57,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; +} + }