From 9b6e5f9cf49df78be25720f9c4b33a733b856c9b Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 18 Jan 2003 07:23:28 +0000 Subject: provide RenderControls to all otk from the display class. initialize them all there. try use bitshifts instead of color tables in the TrueRenderControl class for finding correct rgbs. Move the image/pixmap/xftdraw into the surface class, and it maintains them, recreating them when it resizes. --- otk/rendercontrol.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'otk/rendercontrol.cc') diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index 479de3d9..ef49f7e1 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,47 @@ RenderControl::~RenderControl() } +void RenderControl::drawString(Surface *sf, const Font &font, int x, int y, + const Color &color, const ustring &string) const +{ + assert(sf); + assert(sf->_screen == _screen); + XftDraw *d = sf->_xftdraw; + assert(d); + + 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; +} + } -- cgit v1.2.3