]>
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"
11 #include "screeninfo.hh"
20 #endif // HAVE_STDLIB_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::drawString(Surface
& sf
, const Font
&font
, int x
, int y
,
64 const Color
&color
, const ustring
&string
) const
66 assert(sf
._screen
== _screen
);
67 XftDraw
*d
= sf
._xftdraw
;
68 assert(d
); // this means that the background hasn't been rendered yet!
75 c
.color
.alpha
= font
._tint
| font
._tint
<< 8; // transparent shadow
76 c
.pixel
= BlackPixel(**display
, _screen
);
79 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
80 font
._xftfont
->ascent
+ y
+ font
._offset
,
81 (FcChar8
*)string
.c_str(), string
.bytes());
83 XftDrawString8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
84 font
._xftfont
->ascent
+ y
+ font
._offset
,
85 (FcChar8
*)string
.c_str(), string
.bytes());
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
96 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
97 (FcChar8
*)string
.c_str(), string
.bytes());
99 XftDrawString8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
100 (FcChar8
*)string
.c_str(), string
.bytes());
105 void RenderControl::drawSolidBackground(Surface
& sf
,
106 const RenderTexture
& texture
) const
108 assert(_screen
== sf
._screen
);
109 assert(_screen
== texture
.color().screen());
111 if (texture
.parentRelative()) return;
113 sf
.setPixmap(texture
.color());
115 int width
= sf
.width(), height
= sf
.height();
116 int left
= 0, top
= 0, right
= width
- 1, bottom
= height
- 1;
118 if (texture
.interlaced())
119 for (int i
= 0; i
< height
; i
+= 2)
120 XDrawLine(**display
, sf
.pixmap(), texture
.interlaceColor().gc(),
123 switch (texture
.relief()) {
124 case RenderTexture::Raised
:
125 switch (texture
.bevel()) {
126 case RenderTexture::Bevel1
:
127 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
128 left
, bottom
, right
, bottom
);
129 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
130 right
, bottom
, right
, top
);
132 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
133 left
, top
, right
, top
);
134 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
135 left
, bottom
, left
, top
);
137 case RenderTexture::Bevel2
:
138 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
139 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
140 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
141 right
- 2, bottom
- 2, right
- 2, top
+ 1);
143 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
144 left
+ 1, top
+ 1, right
- 2, top
+ 1);
145 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
146 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
149 assert(false); // unhandled RenderTexture::BevelType
152 case RenderTexture::Sunken
:
153 switch (texture
.bevel()) {
154 case RenderTexture::Bevel1
:
155 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
156 left
, bottom
, right
, bottom
);
157 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
158 right
, bottom
, right
, top
);
160 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
161 left
, top
, right
, top
);
162 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
163 left
, bottom
, left
, top
);
165 case RenderTexture::Bevel2
:
166 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
167 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
168 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
169 right
- 2, bottom
- 2, right
- 2, top
+ 1);
171 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
172 left
+ 1, top
+ 1, right
- 2, top
+ 1);
173 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
174 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
177 assert(false); // unhandled RenderTexture::BevelType
180 case RenderTexture::Flat
:
181 if (texture
.border())
182 XDrawRectangle(**display
, sf
.pixmap(), texture
.borderColor().gc(),
183 left
, top
, right
, bottom
);
186 assert(false); // unhandled RenderTexture::ReliefType
This page took 0.046407 seconds and 4 git commands to generate.