wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit a894cc3bf524bf933917490a8660998eed348cb5
parent 31b93e49b8ec13df2ddcf267db4620b28a16c8ce
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed, 14 Jun 2006 18:59:26 +0200

implemented BlitzTile


Diffstat:
liblitz/Makefile | 2+-
liblitz/blitz.h | 5+++++
liblitz/tile.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/liblitz/Makefile b/liblitz/Makefile @@ -6,7 +6,7 @@ include ../config.mk CFLAGS += -I../libixp -I../libcext LDFLAGS += -L../libixp -lixp -L../libcext -lcext -SRC = blitz.c color.c font.c label.c widget.c +SRC = blitz.c color.c font.c label.c tile.c widget.c OBJ = ${SRC:.c=.o} all: liblitz.a diff --git a/liblitz/blitz.h b/liblitz/blitz.h @@ -17,6 +17,7 @@ typedef struct BlitzFont BlitzFont; typedef struct BlitzTile BlitzTile; typedef struct BlitzInput BlitzInput; typedef union BlitzWidget BlitzWidget; +#define BLITZWIDGET(p) ((BlitzWidget *)(p)) struct Blitz { Display *display; @@ -122,3 +123,7 @@ void blitz_destroy_tile(BlitzTile *t); /* font.c */ unsigned int blitz_textwidth(BlitzFont *font, char *text); void blitz_loadfont(BlitzFont *font, char *fontstr); + +/* widget.c */ +void blitz_add_widget(BlitzWidget *w); +void blitz_rm_widget(BlitzWidget *w); diff --git a/liblitz/tile.c b/liblitz/tile.c @@ -0,0 +1,48 @@ +/* + * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com> + * See LICENSE file for license details. + */ + +#include <stdlib.h> + +#include <cext.h> + +#include "blitz.h" + +BlitzTile * +blitz_create_tile(Drawable drawable, GC gc) +{ + BlitzTile *t = cext_emallocz(sizeof(BlitzTile)); + t->drawable = drawable; + t->gc = gc; + blitz_add_widget(BLITZWIDGET(t)); + return t; +} + +void +blitz_draw_tile(BlitzTile *t) +{ + XPoint points[5]; + XSetForeground(__blitz.display, t->gc, t->color.bg); + XFillRectangles(__blitz.display, t->drawable, t->gc, &t->rect, 1); + XSetLineAttributes(__blitz.display, t->gc, 1, LineSolid, CapButt, JoinMiter); + XSetForeground(__blitz.display, t->gc, t->color.border); + points[0].x = t->rect.x; + points[0].y = t->rect.y; + points[1].x = t->rect.width - 1; + points[1].y = 0; + points[2].x = 0; + points[2].y = t->rect.height - 1; + points[3].x = -(t->rect.width - 1); + points[3].y = 0; + points[4].x = 0; + points[4].y = -(t->rect.height - 1); + XDrawLines(__blitz.display, t->drawable, t->gc, points, 5, CoordModePrevious); +} + +void +blitz_destroy_tile(BlitzTile *t) +{ + blitz_rm_widget(BLITZWIDGET(t)); + free(t); +}