]>
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 "rendertexture.hh"
10 #include "rendercolor.hh"
12 #include "screeninfo.hh"
20 #endif // HAVE_STDLIB_H
22 #include "../src/gettext.h"
23 #define _(str) gettext(str)
28 RenderControl
*RenderControl::getRenderControl(int screen
)
30 // get the visual on the screen and return the correct type of RenderControl
31 int vclass
= display
->screenInfo(screen
)->visual()->c_class
;
34 return new TrueRenderControl(screen
);
37 // return new PseudoRenderControl(screen);
40 // return new GrayRenderControl(screen);
42 printf(_("RenderControl: Unsupported visual %d specified. Aborting.\n"),
48 RenderControl::RenderControl(int screen
)
51 printf("Initializing RenderControl\n");
56 RenderControl::~RenderControl()
58 printf("Destroying RenderControl\n");
63 void RenderControl::drawRoot(const RenderColor
&color
) const
65 Window root
= display
->screenInfo(_screen
)->rootWindow();
66 XSetWindowBackground(**display
, root
, color
.pixel());
67 XClearWindow(**display
, root
);
70 void RenderControl::drawString(Surface
& sf
, const Font
&font
, int x
, int y
,
71 const RenderColor
&color
,
72 const ustring
&string
) const
74 assert(sf
._screen
== _screen
);
75 XftDraw
*d
= sf
._xftdraw
;
76 assert(d
); // this means that the background hasn't been rendered yet!
83 c
.color
.alpha
= font
._tint
| font
._tint
<< 8; // transparent shadow
84 c
.pixel
= BlackPixel(**display
, _screen
);
87 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
88 font
._xftfont
->ascent
+ y
+ font
._offset
,
89 (FcChar8
*)string
.c_str(), string
.bytes());
91 XftDrawString8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
92 font
._xftfont
->ascent
+ y
+ font
._offset
,
93 (FcChar8
*)string
.c_str(), string
.bytes());
97 c
.color
.red
= color
.red() | color
.red() << 8;
98 c
.color
.green
= color
.green() | color
.green() << 8;
99 c
.color
.blue
= color
.blue() | color
.blue() << 8;
100 c
.pixel
= color
.pixel();
101 c
.color
.alpha
= 0xff | 0xff << 8; // no transparency in Color yet
104 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
105 (FcChar8
*)string
.c_str(), string
.bytes());
107 XftDrawString8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
108 (FcChar8
*)string
.c_str(), string
.bytes());
112 void RenderControl::drawSolidBackground(Surface
& sf
,
113 const RenderTexture
& texture
) const
115 assert(_screen
== sf
._screen
);
116 assert(_screen
== texture
.color().screen());
118 if (texture
.parentRelative()) return;
120 sf
.setPixmap(texture
.color());
122 int width
= sf
.width(), height
= sf
.height();
123 int left
= 0, top
= 0, right
= width
- 1, bottom
= height
- 1;
125 if (texture
.interlaced())
126 for (int i
= 0; i
< height
; i
+= 2)
127 XDrawLine(**display
, sf
.pixmap(), texture
.interlaceColor().gc(),
130 switch (texture
.relief()) {
131 case RenderTexture::Raised
:
132 switch (texture
.bevel()) {
133 case RenderTexture::Bevel1
:
134 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
135 left
, bottom
, right
, bottom
);
136 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
137 right
, bottom
, right
, top
);
139 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
140 left
, top
, right
, top
);
141 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
142 left
, bottom
, left
, top
);
144 case RenderTexture::Bevel2
:
145 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
146 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
147 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
148 right
- 2, bottom
- 2, right
- 2, top
+ 1);
150 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
151 left
+ 1, top
+ 1, right
- 2, top
+ 1);
152 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
153 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
156 assert(false); // unhandled RenderTexture::BevelType
159 case RenderTexture::Sunken
:
160 switch (texture
.bevel()) {
161 case RenderTexture::Bevel1
:
162 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
163 left
, bottom
, right
, bottom
);
164 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
165 right
, bottom
, right
, top
);
167 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
168 left
, top
, right
, top
);
169 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
170 left
, bottom
, left
, top
);
172 case RenderTexture::Bevel2
:
173 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
174 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
175 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
176 right
- 2, bottom
- 2, right
- 2, top
+ 1);
178 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
179 left
+ 1, top
+ 1, right
- 2, top
+ 1);
180 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
181 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
184 assert(false); // unhandled RenderTexture::BevelType
187 case RenderTexture::Flat
:
188 if (texture
.border())
189 XDrawRectangle(**display
, sf
.pixmap(), texture
.borderColor().gc(),
190 left
, top
, right
, bottom
);
193 assert(false); // unhandled RenderTexture::ReliefType
This page took 0.044652 seconds and 4 git commands to generate.