X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frendercontrol.cc;h=8046398e304fa7dad3ca5cefeaed4ae44be20675;hb=bb6ac36d410ba62bc8bb481dd6461a30aace42fd;hp=ef49f7e1098b88eecd3483dbda74027787027183;hpb=9b6e5f9cf49df78be25720f9c4b33a733b856c9b;p=chaz%2Fopenbox diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index ef49f7e1..8046398e 100644 --- a/otk/rendercontrol.cc +++ b/otk/rendercontrol.cc @@ -7,10 +7,10 @@ #include "rendercontrol.hh" #include "truerendercontrol.hh" #include "rendertexture.hh" +#include "rendercolor.hh" #include "display.hh" #include "screeninfo.hh" #include "surface.hh" -#include "color.hh" #include "font.hh" #include "ustring.hh" @@ -19,7 +19,7 @@ extern "C" { # include #endif // HAVE_STDLIB_H -#include "gettext.h" +#include "../src/gettext.h" #define _(str) gettext(str) } @@ -60,13 +60,20 @@ RenderControl::~RenderControl() } -void RenderControl::drawString(Surface *sf, const Font &font, int x, int y, - const Color &color, const ustring &string) const +void RenderControl::drawRoot(const RenderColor &color) const { - assert(sf); - assert(sf->_screen == _screen); - XftDraw *d = sf->_xftdraw; - assert(d); + Window root = display->screenInfo(_screen)->rootWindow(); + XSetWindowBackground(**display, root, color.pixel()); + XClearWindow(**display, root); +} + +void RenderControl::drawString(Surface& sf, const Font &font, int x, int y, + const RenderColor &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; @@ -99,8 +106,92 @@ void RenderControl::drawString(Surface *sf, const Font &font, int x, int y, else XftDrawString8(d, &c, font._xftfont, x, font._xftfont->ascent + y, (FcChar8*)string.c_str(), string.bytes()); - return; } +void RenderControl::drawSolidBackground(Surface& sf, + const RenderTexture& texture) const +{ + assert(_screen == sf._screen); + assert(_screen == texture.color().screen()); + + if (texture.parentRelative()) return; + + sf.setPixmap(texture.color()); + + int width = sf.width(), height = sf.height(); + int left = 0, top = 0, right = width - 1, bottom = height - 1; + + if (texture.interlaced()) + for (int i = 0; i < height; i += 2) + XDrawLine(**display, sf.pixmap(), texture.interlaceColor().gc(), + 0, i, width, i); + + switch (texture.relief()) { + case RenderTexture::Raised: + switch (texture.bevel()) { + case RenderTexture::Bevel1: + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + left, bottom, right, bottom); + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + right, bottom, right, top); + + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + left, top, right, top); + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + left, bottom, left, top); + break; + case RenderTexture::Bevel2: + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + left + 1, bottom - 2, right - 2, bottom - 2); + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + right - 2, bottom - 2, right - 2, top + 1); + + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + left + 1, top + 1, right - 2, top + 1); + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + left + 1, bottom - 2, left + 1, top + 1); + break; + default: + assert(false); // unhandled RenderTexture::BevelType + } + break; + case RenderTexture::Sunken: + switch (texture.bevel()) { + case RenderTexture::Bevel1: + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + left, bottom, right, bottom); + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + right, bottom, right, top); + + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + left, top, right, top); + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + left, bottom, left, top); + break; + case RenderTexture::Bevel2: + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + left + 1, bottom - 2, right - 2, bottom - 2); + XDrawLine(**display, sf.pixmap(), texture.bevelLightColor().gc(), + right - 2, bottom - 2, right - 2, top + 1); + + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + left + 1, top + 1, right - 2, top + 1); + XDrawLine(**display, sf.pixmap(), texture.bevelDarkColor().gc(), + left + 1, bottom - 2, left + 1, top + 1); + break; + default: + assert(false); // unhandled RenderTexture::BevelType + } + break; + case RenderTexture::Flat: + if (texture.border()) + XDrawRectangle(**display, sf.pixmap(), texture.borderColor().gc(), + left, top, right, bottom); + break; + default: + assert(false); // unhandled RenderTexture::ReliefType + } +} + }