X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=otk%2Frendercontrol.cc;h=aae6c76bfa3a01f02b3c82f06c3f15f74de8c6e3;hb=afb8a28120b21569934202968283e65a173c3bd8;hp=0f84af892b22b2dc68c75f6d7df385056687229b;hpb=d8d9b42777ace234f3471918e1210062578f8188;p=chaz%2Fopenbox diff --git a/otk/rendercontrol.cc b/otk/rendercontrol.cc index 0f84af89..aae6c76b 100644 --- a/otk/rendercontrol.cc +++ b/otk/rendercontrol.cc @@ -6,11 +6,12 @@ #include "rendercontrol.hh" #include "truerendercontrol.hh" +#include "pseudorendercontrol.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 +20,7 @@ extern "C" { # include #endif // HAVE_STDLIB_H -#include "gettext.h" +#include "../src/gettext.h" #define _(str) gettext(str) } @@ -34,10 +35,10 @@ RenderControl *RenderControl::getRenderControl(int screen) return new TrueRenderControl(screen); case PseudoColor: case StaticColor: -// return new PseudoRenderControl(screen); + return new PseudoRenderControl(screen); case GrayScale: case StaticGray: -// return new GrayRenderControl(screen); + return new PseudoRenderControl(screen); default: printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"), vclass); @@ -60,8 +61,16 @@ RenderControl::~RenderControl() } +void RenderControl::drawRoot(const RenderColor &color) const +{ + 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 Color &color, const ustring &string) const + const RenderColor &color, + const ustring &string) const { assert(sf._screen == _screen); XftDraw *d = sf._xftdraw; @@ -98,8 +107,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 + } +} + }