Mercurial > aewl
comparison draw.c @ 353:8a06efe5b563
new color stuff/new rendering stuff
author | Anselm R. Garbe <arg@10kloc.org> |
---|---|
date | Fri, 25 Aug 2006 12:59:45 +0200 |
parents | 5a8bdc3b37cb |
children | f9543a4af9e5 |
comparison
equal
deleted
inserted
replaced
352:5a8bdc3b37cb | 353:8a06efe5b563 |
---|---|
20 } | 20 } |
21 return XTextWidth(dc.font.xfont, text, len); | 21 return XTextWidth(dc.font.xfont, text, len); |
22 } | 22 } |
23 | 23 |
24 static void | 24 static void |
25 drawtext(const char *text, Bool invert, Bool highlight) | 25 drawtext(const char *text, unsigned long col[ColLast], Bool highlight) |
26 { | 26 { |
27 int x, y, w, h; | 27 int x, y, w, h; |
28 static char buf[256]; | 28 static char buf[256]; |
29 unsigned int len, olen; | 29 unsigned int len, olen; |
30 XGCValues gcv; | 30 XGCValues gcv; |
31 XPoint points[5]; | |
32 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; | 31 XRectangle r = { dc.x, dc.y, dc.w, dc.h }; |
33 | 32 |
34 XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); | 33 XSetForeground(dpy, dc.gc, col[ColBG]); |
35 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); | 34 XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); |
36 points[0].x = dc.x; | |
37 points[0].y = dc.y; | |
38 points[1].x = dc.w - 1; | |
39 points[1].y = 0; | |
40 points[2].x = 0; | |
41 points[2].y = dc.h - 1; | |
42 points[3].x = -(dc.w - 1); | |
43 points[3].y = 0; | |
44 points[4].x = 0; | |
45 points[4].y = -(dc.h - 1); | |
46 XSetForeground(dpy, dc.gc, dc.border); | |
47 XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); | |
48 | 35 |
49 if(!text) | 36 if(!text) |
50 return; | 37 return; |
51 | 38 |
52 w = 0; | 39 w = 0; |
72 buf[len - 3] = '.'; | 59 buf[len - 3] = '.'; |
73 } | 60 } |
74 | 61 |
75 if(w > dc.w) | 62 if(w > dc.w) |
76 return; /* too long */ | 63 return; /* too long */ |
77 gcv.foreground = invert ? dc.bg : dc.fg; | 64 gcv.foreground = col[ColFG]; |
78 gcv.background = invert ? dc.fg : dc.bg; | |
79 if(dc.font.set) { | 65 if(dc.font.set) { |
80 XChangeGC(dpy, dc.gc, GCForeground | GCBackground, &gcv); | 66 XChangeGC(dpy, dc.gc, GCForeground, &gcv); |
81 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); | 67 XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); |
82 } | 68 } |
83 else { | 69 else { |
84 gcv.font = dc.font.xfont->fid; | 70 gcv.font = dc.font.xfont->fid; |
85 XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); | 71 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); |
86 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); | 72 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); |
87 } | 73 } |
88 if(highlight) { | 74 if(highlight) { |
89 r.x = dc.x + 2; | 75 r.x = dc.x + 2; |
90 r.y = dc.y + 2; | 76 r.y = dc.y + 2; |
106 } | 92 } |
107 | 93 |
108 void | 94 void |
109 drawstatus() | 95 drawstatus() |
110 { | 96 { |
97 static const char *mode[] = { "~", "=" }; | |
111 int i, x; | 98 int i, x; |
112 Bool istile = arrange == dotile; | |
113 | 99 |
114 dc.x = dc.y = 0; | 100 dc.x = dc.y = 0; |
115 dc.w = bw; | 101 dc.w = bw; |
116 drawtext(NULL, !istile, False); | 102 |
103 if(!modew) | |
104 modew = textw(mode[0]) > textw(mode[1]) ? textw(mode[0]) : textw(mode[1]); | |
105 drawtext(mode[arrange == dotile ? 1 : 0], dc.status, False); | |
117 | 106 |
118 dc.w = 0; | 107 dc.w = 0; |
108 dc.x = modew; | |
119 for(i = 0; i < ntags; i++) { | 109 for(i = 0; i < ntags; i++) { |
120 dc.x += dc.w; | 110 dc.x += dc.w; |
121 dc.w = textw(tags[i]); | 111 dc.w = textw(tags[i]); |
122 if(istile) | 112 if(seltag[i]) |
123 drawtext(tags[i], seltag[i], sel && sel->tags[i]); | 113 drawtext(tags[i], dc.sel, sel && sel->tags[i]); |
124 else | 114 else |
125 drawtext(tags[i], !seltag[i], sel && sel->tags[i]); | 115 drawtext(tags[i], dc.norm, sel && sel->tags[i]); |
126 } | 116 } |
127 x = dc.x + dc.w; | 117 x = dc.x + dc.w; |
128 dc.w = textw(stext); | 118 dc.w = textw(stext); |
129 dc.x = bx + bw - dc.w; | 119 dc.x = bx + bw - dc.w; |
130 if(dc.x < x) { | 120 if(dc.x < x) { |
131 dc.x = x; | 121 dc.x = x; |
132 dc.w = bw - x; | 122 dc.w = bw - x; |
133 } | 123 } |
134 drawtext(stext, !istile, False); | 124 drawtext(stext, dc.status, False); |
135 | 125 |
136 if(sel && ((dc.w = dc.x - x) > bh)) { | 126 if(sel && ((dc.w = dc.x - x) > bh)) { |
137 dc.x = x; | 127 dc.x = x; |
138 drawtext(sel->name, istile, False); | 128 drawtext(sel->name, dc.sel, False); |
139 } | 129 } |
140 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); | 130 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); |
141 XSync(dpy, False); | 131 XSync(dpy, False); |
142 } | 132 } |
143 | 133 |
144 void | 134 void |
145 drawtitle(Client *c) | 135 drawtitle(Client *c) |
146 { | 136 { |
147 int i; | 137 int i; |
148 Bool istile = arrange == dotile; | |
149 | 138 |
150 if(c == sel && issel) { | 139 if(c == sel && issel) { |
151 drawstatus(); | 140 drawstatus(); |
152 XUnmapWindow(dpy, c->twin); | 141 XUnmapWindow(dpy, c->twin); |
153 XSetWindowBorder(dpy, c->win, dc.fg); | 142 XSetWindowBorder(dpy, c->win, dc.sel[ColBG]); |
154 return; | 143 return; |
155 } | 144 } |
156 | 145 |
157 XSetWindowBorder(dpy, c->win, dc.bg); | 146 XSetWindowBorder(dpy, c->win, dc.norm[ColBG]); |
158 XMapWindow(dpy, c->twin); | 147 XMapWindow(dpy, c->twin); |
159 dc.x = dc.y = 0; | 148 dc.x = dc.y = 0; |
160 dc.w = c->tw; | 149 dc.w = c->tw; |
161 drawtext(c->name, !istile, False); | 150 drawtext(c->name, dc.norm, False); |
162 XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); | 151 XCopyArea(dpy, dc.drawable, c->twin, dc.gc, 0, 0, c->tw, c->th, 0, 0); |
163 XSync(dpy, False); | 152 XSync(dpy, False); |
164 } | 153 } |
165 | 154 |
166 unsigned long | 155 unsigned long |