]>
Dogcows Code - chaz/openbox/blob - otk/rendercontrol.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
5 #endif // HAVE_CONFIG_H
7 #include "rendercontrol.hh"
8 #include "truerendercontrol.hh"
9 #include "pseudorendercontrol.hh"
10 #include "rendertexture.hh"
11 #include "rendercolor.hh"
13 #include "screeninfo.hh"
21 #endif // HAVE_STDLIB_H
23 #include "../src/gettext.h"
24 #define _(str) gettext(str)
29 RenderControl
*RenderControl::getRenderControl(int screen
)
31 // get the visual on the screen and return the correct type of RenderControl
32 int vclass
= display
->screenInfo(screen
)->visual()->c_class
;
35 return new TrueRenderControl(screen
);
38 return new PseudoRenderControl(screen
);
41 return new PseudoRenderControl(screen
);
43 printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
49 RenderControl::RenderControl(int screen
)
52 printf("Initializing RenderControl\n");
57 RenderControl::~RenderControl()
59 printf("Destroying RenderControl\n");
64 void RenderControl::drawRoot(const RenderColor
&color
) const
66 Window root
= display
->screenInfo(_screen
)->rootWindow();
67 XSetWindowBackground(**display
, root
, color
.pixel());
68 XClearWindow(**display
, root
);
71 void RenderControl::drawString(Surface
& sf
, const Font
&font
, int x
, int y
,
72 const RenderColor
&color
,
73 const ustring
&string
) const
75 assert(sf
._screen
== _screen
);
76 XftDraw
*d
= sf
._xftdraw
;
77 assert(d
); // this means that the background hasn't been rendered yet!
84 c
.color
.alpha
= font
._tint
| font
._tint
<< 8; // transparent shadow
85 c
.pixel
= BlackPixel(**display
, _screen
);
88 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
89 font
._xftfont
->ascent
+ y
+ font
._offset
,
90 (FcChar8
*)string
.c_str(), string
.bytes());
92 XftDrawString8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
93 font
._xftfont
->ascent
+ y
+ font
._offset
,
94 (FcChar8
*)string
.c_str(), string
.bytes());
98 c
.color
.red
= color
.red() | color
.red() << 8;
99 c
.color
.green
= color
.green() | color
.green() << 8;
100 c
.color
.blue
= color
.blue() | color
.blue() << 8;
101 c
.pixel
= color
.pixel();
102 c
.color
.alpha
= 0xff | 0xff << 8; // no transparency in Color yet
105 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
106 (FcChar8
*)string
.c_str(), string
.bytes());
108 XftDrawString8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
109 (FcChar8
*)string
.c_str(), string
.bytes());
113 void RenderControl::drawSolidBackground(Surface
& sf
,
114 const RenderTexture
& texture
) const
116 assert(_screen
== sf
._screen
);
117 assert(_screen
== texture
.color().screen());
119 if (texture
.parentRelative()) return;
121 sf
.setPixmap(texture
.color());
123 int width
= sf
.width(), height
= sf
.height();
124 int left
= 0, top
= 0, right
= width
- 1, bottom
= height
- 1;
126 if (texture
.interlaced())
127 for (int i
= 0; i
< height
; i
+= 2)
128 XDrawLine(**display
, sf
.pixmap(), texture
.interlaceColor().gc(),
131 switch (texture
.relief()) {
132 case RenderTexture::Raised
:
133 switch (texture
.bevel()) {
134 case RenderTexture::Bevel1
:
135 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
136 left
, bottom
, right
, bottom
);
137 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
138 right
, bottom
, right
, top
);
140 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
141 left
, top
, right
, top
);
142 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
143 left
, bottom
, left
, top
);
145 case RenderTexture::Bevel2
:
146 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
147 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
148 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
149 right
- 2, bottom
- 2, right
- 2, top
+ 1);
151 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
152 left
+ 1, top
+ 1, right
- 2, top
+ 1);
153 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
154 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
157 assert(false); // unhandled RenderTexture::BevelType
160 case RenderTexture::Sunken
:
161 switch (texture
.bevel()) {
162 case RenderTexture::Bevel1
:
163 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
164 left
, bottom
, right
, bottom
);
165 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
166 right
, bottom
, right
, top
);
168 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
169 left
, top
, right
, top
);
170 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
171 left
, bottom
, left
, top
);
173 case RenderTexture::Bevel2
:
174 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
175 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
176 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
177 right
- 2, bottom
- 2, right
- 2, top
+ 1);
179 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
180 left
+ 1, top
+ 1, right
- 2, top
+ 1);
181 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
182 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
185 assert(false); // unhandled RenderTexture::BevelType
188 case RenderTexture::Flat
:
189 if (texture
.border())
190 XDrawRectangle(**display
, sf
.pixmap(), texture
.borderColor().gc(),
191 left
, top
, right
, bottom
);
194 assert(false); // unhandled RenderTexture::ReliefType
This page took 0.041736 seconds and 4 git commands to generate.