implemented BlitzTile

This commit is contained in:
Anselm R. Garbe 2006-06-14 18:59:26 +02:00
parent 31b93e49b8
commit a894cc3bf5
3 changed files with 54 additions and 1 deletions

View File

@ -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

View File

@ -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);

48
liblitz/tile.c Normal file
View File

@ -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);
}