Mercurial > dwm-meillo
comparison draw.c @ 257:32dc3acfffc0
simplified drawtext
author | Anselm R.Garbe <arg@10ksloc.org> |
---|---|
date | Fri, 11 Aug 2006 11:52:55 +0200 |
parents | e5390f8e06b9 |
children | d6fd632d861c |
comparison
equal
deleted
inserted
replaced
256:b37acb9ead8c | 257:32dc3acfffc0 |
---|---|
7 #include <string.h> | 7 #include <string.h> |
8 #include <X11/Xlocale.h> | 8 #include <X11/Xlocale.h> |
9 | 9 |
10 /* static */ | 10 /* static */ |
11 | 11 |
12 static unsigned int | |
13 textnw(const char *text, unsigned int len) | |
14 { | |
15 XRectangle r; | |
16 | |
17 if(dc.font.set) { | |
18 XmbTextExtents(dc.font.set, text, len, NULL, &r); | |
19 return r.width; | |
20 } | |
21 return XTextWidth(dc.font.xfont, text, len); | |
22 } | |
23 | |
12 static void | 24 static void |
13 drawborder(void) | 25 drawtext(const char *text, Bool invert) |
14 { | 26 { |
27 int x, y, w, h; | |
28 static char buf[256]; | |
29 unsigned int len; | |
30 XGCValues gcv; | |
15 XPoint points[5]; | 31 XPoint points[5]; |
16 | 32 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
33 | |
34 XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); | |
35 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | |
17 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); | 36 XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); |
18 XSetForeground(dpy, dc.gc, dc.border); | 37 XSetForeground(dpy, dc.gc, dc.border); |
19 points[0].x = dc.x; | 38 points[0].x = dc.x; |
20 points[0].y = dc.y; | 39 points[0].y = dc.y; |
21 points[1].x = dc.w - 1; | 40 points[1].x = dc.w - 1; |
25 points[3].x = -(dc.w - 1); | 44 points[3].x = -(dc.w - 1); |
26 points[3].y = 0; | 45 points[3].y = 0; |
27 points[4].x = 0; | 46 points[4].x = 0; |
28 points[4].y = -(dc.h - 1); | 47 points[4].y = -(dc.h - 1); |
29 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); | 48 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); |
30 } | |
31 | |
32 static unsigned int | |
33 textnw(const char *text, unsigned int len) | |
34 { | |
35 XRectangle r; | |
36 | |
37 if(dc.font.set) { | |
38 XmbTextExtents(dc.font.set, text, len, NULL, &r); | |
39 return r.width; | |
40 } | |
41 return XTextWidth(dc.font.xfont, text, len); | |
42 } | |
43 | |
44 static void | |
45 drawtext(const char *text, Bool invert) | |
46 { | |
47 int x, y, w, h; | |
48 static char buf[256]; | |
49 unsigned int len; | |
50 XGCValues gcv; | |
51 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | |
52 | |
53 XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); | |
54 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | |
55 drawborder(); | |
56 | 49 |
57 if(!text) | 50 if(!text) |
58 return; | 51 return; |
59 | 52 |
60 w = 0; | 53 w = 0; |