commit 31b93e49b8ec13df2ddcf267db4620b28a16c8ce
parent 287611b1db5dc1f67b653d860df35966ec4f801b
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Wed, 14 Jun 2006 18:42:47 +0200
widget list is necessary after all to provide sane hooks to event-check various stuff in liblitz on text input/mouse input
Diffstat:
3 files changed, 56 insertions(+), 5 deletions(-)
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
+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
@@ -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
@@ -0,0 +1,28 @@
+/*
+ * (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"
+
+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;
+}