]> Dogcows Code - chaz/openbox/blob - otk/rendercontrol.cc
widegt using new render system
[chaz/openbox] / otk / rendercontrol.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif // HAVE_CONFIG_H
6
7 #include "rendercontrol.hh"
8 #include "truerendercontrol.hh"
9 #include "rendertexture.hh"
10 #include "display.hh"
11 #include "screeninfo.hh"
12 #include "surface.hh"
13 #include "color.hh"
14 #include "font.hh"
15 #include "ustring.hh"
16
17 extern "C" {
18 #ifdef HAVE_STDLIB_H
19 # include <stdlib.h>
20 #endif // HAVE_STDLIB_H
21
22 #include "gettext.h"
23 #define _(str) gettext(str)
24 }
25
26 namespace otk {
27
28 RenderControl *RenderControl::getRenderControl(int screen)
29 {
30 // get the visual on the screen and return the correct type of RenderControl
31 int vclass = display->screenInfo(screen)->visual()->c_class;
32 switch (vclass) {
33 case TrueColor:
34 return new TrueRenderControl(screen);
35 case PseudoColor:
36 case StaticColor:
37 // return new PseudoRenderControl(screen);
38 case GrayScale:
39 case StaticGray:
40 // return new GrayRenderControl(screen);
41 default:
42 printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
43 vclass);
44 ::exit(1);
45 }
46 }
47
48 RenderControl::RenderControl(int screen)
49 : _screen(screen)
50 {
51 printf("Initializing RenderControl\n");
52
53
54 }
55
56 RenderControl::~RenderControl()
57 {
58 printf("Destroying RenderControl\n");
59
60
61 }
62
63 void RenderControl::drawString(Surface& sf, const Font &font, int x, int y,
64 const Color &color, const ustring &string) const
65 {
66 assert(sf._screen == _screen);
67 XftDraw *d = sf._xftdraw;
68 assert(d); // this means that the background hasn't been rendered yet!
69
70 if (font._shadow) {
71 XftColor c;
72 c.color.red = 0;
73 c.color.green = 0;
74 c.color.blue = 0;
75 c.color.alpha = font._tint | font._tint << 8; // transparent shadow
76 c.pixel = BlackPixel(**display, _screen);
77
78 if (string.utf8())
79 XftDrawStringUtf8(d, &c, font._xftfont, x + font._offset,
80 font._xftfont->ascent + y + font._offset,
81 (FcChar8*)string.c_str(), string.bytes());
82 else
83 XftDrawString8(d, &c, font._xftfont, x + font._offset,
84 font._xftfont->ascent + y + font._offset,
85 (FcChar8*)string.c_str(), string.bytes());
86 }
87
88 XftColor c;
89 c.color.red = color.red() | color.red() << 8;
90 c.color.green = color.green() | color.green() << 8;
91 c.color.blue = color.blue() | color.blue() << 8;
92 c.pixel = color.pixel();
93 c.color.alpha = 0xff | 0xff << 8; // no transparency in Color yet
94
95 if (string.utf8())
96 XftDrawStringUtf8(d, &c, font._xftfont, x, font._xftfont->ascent + y,
97 (FcChar8*)string.c_str(), string.bytes());
98 else
99 XftDrawString8(d, &c, font._xftfont, x, font._xftfont->ascent + y,
100 (FcChar8*)string.c_str(), string.bytes());
101
102 return;
103 }
104
105 }
This page took 0.040918 seconds and 5 git commands to generate.