]>
Dogcows Code - chaz/openbox/blob - rendercontrol.cc
1bb59c80cf7e2099c24e9240acca1ca8aa2d2c4e
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
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 RenderColor
&color
,
65 const ustring
&string
) const
67 assert(sf
._screen
== _screen
);
68 XftDraw
*d
= sf
._xftdraw
;
69 assert(d
); // this means that the background hasn't been rendered yet!
76 c
.color
.alpha
= font
._tint
| font
._tint
<< 8; // transparent shadow
77 c
.pixel
= BlackPixel(**display
, _screen
);
80 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
81 font
._xftfont
->ascent
+ y
+ font
._offset
,
82 (FcChar8
*)string
.c_str(), string
.bytes());
84 XftDrawString8(d
, &c
, font
._xftfont
, x
+ font
._offset
,
85 font
._xftfont
->ascent
+ y
+ font
._offset
,
86 (FcChar8
*)string
.c_str(), string
.bytes());
90 c
.color
.red
= color
.red() | color
.red() << 8;
91 c
.color
.green
= color
.green() | color
.green() << 8;
92 c
.color
.blue
= color
.blue() | color
.blue() << 8;
93 c
.pixel
= color
.pixel();
94 c
.color
.alpha
= 0xff | 0xff << 8; // no transparency in Color yet
97 XftDrawStringUtf8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
98 (FcChar8
*)string
.c_str(), string
.bytes());
100 XftDrawString8(d
, &c
, font
._xftfont
, x
, font
._xftfont
->ascent
+ y
,
101 (FcChar8
*)string
.c_str(), string
.bytes());
102 printf("DRAW A STRING!: %s\n", string
.c_str());
106 void RenderControl::drawSolidBackground(Surface
& sf
,
107 const RenderTexture
& texture
) const
109 assert(_screen
== sf
._screen
);
110 assert(_screen
== texture
.color().screen());
112 if (texture
.parentRelative()) return;
114 sf
.setPixmap(texture
.color());
116 int width
= sf
.width(), height
= sf
.height();
117 int left
= 0, top
= 0, right
= width
- 1, bottom
= height
- 1;
119 if (texture
.interlaced())
120 for (int i
= 0; i
< height
; i
+= 2)
121 XDrawLine(**display
, sf
.pixmap(), texture
.interlaceColor().gc(),
124 switch (texture
.relief()) {
125 case RenderTexture::Raised
:
126 switch (texture
.bevel()) {
127 case RenderTexture::Bevel1
:
128 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
129 left
, bottom
, right
, bottom
);
130 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
131 right
, bottom
, right
, top
);
133 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
134 left
, top
, right
, top
);
135 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
136 left
, bottom
, left
, top
);
138 case RenderTexture::Bevel2
:
139 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
140 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
141 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
142 right
- 2, bottom
- 2, right
- 2, top
+ 1);
144 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
145 left
+ 1, top
+ 1, right
- 2, top
+ 1);
146 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
147 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
150 assert(false); // unhandled RenderTexture::BevelType
153 case RenderTexture::Sunken
:
154 switch (texture
.bevel()) {
155 case RenderTexture::Bevel1
:
156 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
157 left
, bottom
, right
, bottom
);
158 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
159 right
, bottom
, right
, top
);
161 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
162 left
, top
, right
, top
);
163 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
164 left
, bottom
, left
, top
);
166 case RenderTexture::Bevel2
:
167 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
168 left
+ 1, bottom
- 2, right
- 2, bottom
- 2);
169 XDrawLine(**display
, sf
.pixmap(), texture
.bevelLightColor().gc(),
170 right
- 2, bottom
- 2, right
- 2, top
+ 1);
172 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
173 left
+ 1, top
+ 1, right
- 2, top
+ 1);
174 XDrawLine(**display
, sf
.pixmap(), texture
.bevelDarkColor().gc(),
175 left
+ 1, bottom
- 2, left
+ 1, top
+ 1);
178 assert(false); // unhandled RenderTexture::BevelType
181 case RenderTexture::Flat
:
182 if (texture
.border())
183 XDrawRectangle(**display
, sf
.pixmap(), texture
.borderColor().gc(),
184 left
, top
, right
, bottom
);
187 assert(false); // unhandled RenderTexture::ReliefType
This page took 0.043423 seconds and 3 git commands to generate.