summaryrefslogtreecommitdiff
path: root/draw/drawtext.c
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2010-06-30 01:36:15 +0100
committerConnor Lane Smith <cls@lubutu.com>2010-06-30 01:36:15 +0100
commit26b9f3de0ffe471e5335b07454147457e373c037 (patch)
tree5480fedbc318d490a4e90c2104d6ba8c26258698 /draw/drawtext.c
parent7afd296c40a2e8af9477add1c3d02a7c4b444747 (diff)
libdraw now has own repo
Diffstat (limited to 'draw/drawtext.c')
-rw-r--r--draw/drawtext.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/draw/drawtext.c b/draw/drawtext.c
deleted file mode 100644
index d347b36..0000000
--- a/draw/drawtext.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include <string.h>
-#include <X11/Xlib.h>
-#include "draw.h"
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-
-void
-drawtext(DC *dc, const char *text, unsigned long col[ColLast], Bool invert) {
- char buf[256];
- int i, x, y, h, len, olen;
- XRectangle r = { dc->x, dc->y, dc->w, dc->h };
-
- XSetForeground(dc->dpy, dc->gc, col[invert ? ColFG : ColBG]);
- XFillRectangles(dc->dpy, dc->drawable, dc->gc, &r, 1);
- if(!text)
- return;
- olen = strlen(text);
- h = dc->font.height;
- y = dc->y + ((h+2) / 2) - (h / 2) + dc->font.ascent;
- x = dc->x + (h / 2);
- /* shorten text if necessary */
- for(len = MIN(olen, sizeof buf); len && textnw(dc, text, len) > dc->w - h; len--);
- if(!len)
- return;
- memcpy(buf, text, len);
- if(len < olen)
- for(i = len; i && i > len - 3; buf[--i] = '.');
- XSetForeground(dc->dpy, dc->gc, col[invert ? ColBG : ColFG]);
- if(dc->font.set)
- XmbDrawString(dc->dpy, dc->drawable, dc->font.set, dc->gc, x, y, buf, len);
- else
- XDrawString(dc->dpy, dc->drawable, dc->gc, x, y, buf, len);
-}