From 31b93e49b8ec13df2ddcf267db4620b28a16c8ce Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Wed, 14 Jun 2006 18:42:47 +0200 Subject: [PATCH] widget list is necessary after all to provide sane hooks to event-check various stuff in liblitz on text input/mouse input --- liblitz/Makefile | 2 +- liblitz/blitz.h | 31 +++++++++++++++++++++++++++---- liblitz/widget.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 liblitz/widget.c diff --git a/liblitz/Makefile b/liblitz/Makefile index 109db930..230c83cc 100644 --- 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 +SRC = blitz.c color.c font.c label.c widget.c OBJ = ${SRC:.c=.o} all: liblitz.a diff --git a/liblitz/blitz.h b/liblitz/blitz.h index e3bf2e6c..7ea8861b 100644 --- a/liblitz/blitz.h +++ b/liblitz/blitz.h @@ -16,11 +16,13 @@ typedef struct BlitzColor BlitzColor; typedef struct BlitzFont BlitzFont; typedef struct BlitzTile BlitzTile; typedef struct BlitzInput BlitzInput; +typedef union BlitzWidget BlitzWidget; struct Blitz { Display *display; int screen; Window root; + BlitzWidget *widgets; }; enum BlitzAlign { @@ -50,20 +52,35 @@ struct BlitzFont { struct BlitzTile { Drawable drawable; + GC gc; + void (*event[LASTEvent]) (BlitzWidget *, XEvent *); + BlitzWidget *next; + /* widget specific */ BlitzColor color; XRectangle rect; /* relative rect */ XRectangle *notch; /* relative notch rect */ - void (*event[LASTEvent]) (BlitzTile *, XEvent *); }; struct BlitzInput { Drawable drawable; + GC gc; + void (*event[LASTEvent]) (BlitzWidget *, XEvent *); + BlitzWidget *next; + /* widget specific */ BlitzColor color; BlitzAlign align; BlitzFont font; XRectangle rect; /* relative rect */ char *text; - void (*event[LASTEvent]) (BlitzInput *, XEvent *); +}; + +union BlitzWidget { + Drawable drawable; + GC gc; + void (*event[LASTEvent]) (BlitzWidget *, XEvent *); + BlitzWidget *next; + BlitzTile tile; + BlitzInput input; }; /* obsolete, will be replaced soon */ @@ -92,9 +109,15 @@ int blitz_loadcolor(BlitzColor *c, char *colstr); void blitz_drawlabel(BlitzDraw *d); void blitz_drawborder(BlitzDraw *d); +/* input.c */ +BlitzInput *blitz_create_input(Drawable drawable, GC gc); +void blitz_draw_input(BlitzInput *t, char *text); +void blitz_destroy_input(BlitzInput *t); + /* tile.c */ -void blitz_drawlabel(BlitzDraw *d); -void blitz_drawborder(BlitzDraw *d); +BlitzTile *blitz_create_tile(Drawable drawable, GC gc); +void blitz_draw_tile(BlitzTile *t); +void blitz_destroy_tile(BlitzTile *t); /* font.c */ unsigned int blitz_textwidth(BlitzFont *font, char *text); diff --git a/liblitz/widget.c b/liblitz/widget.c new file mode 100644 index 00000000..ff8c1647 --- /dev/null +++ b/liblitz/widget.c @@ -0,0 +1,28 @@ +/* + * (C)opyright MMIV-MMVI Anselm R. Garbe + * See LICENSE file for license details. + */ + +#include + +#include + +#include "blitz.h" + +void +blitz_add_widget(BlitzWidget *w) +{ + BlitzWidget **wp; + for(wp = &__blitz.widgets; *wp; wp = &(*wp)->next); + w->next = nil; + *wp = w; +} + +void +blitz_rm_widget(BlitzWidget *w) +{ + BlitzWidget **wp; + for(wp = &__blitz.widgets; *wp && *wp != w; wp = &(*wp)->next); + cext_assert(*wp == w); + *wp = w->next; +}