summaryrefslogtreecommitdiff
path: root/draw/drawsquare.c
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2010-06-28 06:09:34 +0100
committerConnor Lane Smith <cls@lubutu.com>2010-06-28 06:09:34 +0100
commit18dcf738967a45208e880b72ce273afdd93ee6c7 (patch)
tree750ef101f905125871cd63e6734cbbae25f4cb44 /draw/drawsquare.c
parent9f3b0c6ea843340b87a045ea0afd2d1b33425eee (diff)
extended libdraw
Diffstat (limited to 'draw/drawsquare.c')
-rw-r--r--draw/drawsquare.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/draw/drawsquare.c b/draw/drawsquare.c
new file mode 100644
index 0000000..8899043
--- /dev/null
+++ b/draw/drawsquare.c
@@ -0,0 +1,19 @@
+/* See LICENSE file for copyright and license details. */
+#include <X11/Xlib.h>
+#include "draw.h"
+
+void
+drawsquare(DC *dc, Bool filled, unsigned long col[ColLast], Bool invert) {
+ int n;
+ XRectangle r = { dc->x, dc->y, dc->w, dc->h };
+
+ XSetForeground(dc->dpy, dc->gc, col[invert ? ColBG : ColFG]);
+ n = ((dc->font.ascent + dc->font.descent + 2) / 4) + (filled ? 1 : 0);
+ r.width = r.height = n;
+ r.x = dc->x + 1;
+ r.y = dc->y + 1;
+ if(filled)
+ XFillRectangles(dc->dpy, dc->drawable, dc->gc, &r, 1);
+ else
+ XDrawRectangles(dc->dpy, dc->drawable, dc->gc, &r, 1);
+}