widget list is necessary after all to provide sane hooks to event-check various stuff in liblitz on text input/mouse input

This commit is contained in:
Anselm R. Garbe 2006-06-14 18:42:47 +02:00
parent 287611b1db
commit 31b93e49b8
3 changed files with 56 additions and 5 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
SRC = blitz.c color.c font.c label.c widget.c
OBJ = ${SRC:.c=.o}
all: liblitz.a

View File

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

28
liblitz/widget.c Normal file
View File

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