commit 287611b1db5dc1f67b653d860df35966ec4f801b
parent f163e3592ef818f2a882930768659c31c099c146
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Wed, 14 Jun 2006 18:23:49 +0200
removed various crap from liblitz, this toolkit-idea is the wrong starting point, let's first have BlitzInput and BlitzTile widgets and do the event handling in the client app first
Diffstat:
5 files changed, 16 insertions(+), 181 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 layout.c window.c widget.c
+SRC = blitz.c color.c font.c label.c
OBJ = ${SRC:.c=.o}
all: liblitz.a
diff --git a/liblitz/blitz.h b/liblitz/blitz.h
@@ -14,13 +14,8 @@ typedef struct Blitz Blitz;
typedef enum BlitzAlign BlitzAlign;
typedef struct BlitzColor BlitzColor;
typedef struct BlitzFont BlitzFont;
-typedef struct BlitzLabel BlitzLabel;
-#define BLITZLABEL(p) ((BlitzLabel *)(p))
-typedef struct BlitzLayout BlitzLayout;
-#define BLITZLAYOUT(p) ((BlitzLayout *)(p))
-typedef union BlitzWidget BlitzWidget;
-#define BLITZWIDGET(p) ((BlitzWidget *)(p))
-typedef struct BlitzWin BlitzWin;
+typedef struct BlitzTile BlitzTile;
+typedef struct BlitzInput BlitzInput;
struct Blitz {
Display *display;
@@ -53,46 +48,22 @@ struct BlitzFont {
int descent;
};
-struct BlitzWin{
+struct BlitzTile {
Drawable drawable;
- GC gc;
- XRectangle rect;
-};
-
-struct BlitzLayout {
- XRectangle rect;
- Bool expand;
- BlitzWidget *next;
- void (*draw)(BlitzWidget *);
- void (*destroy)(BlitzWidget *);
- /* widget specific */
- BlitzWin *win;
- BlitzWidget *rows;
- BlitzWidget *cols;
- void (*scale)(BlitzWidget *);
+ BlitzColor color;
+ XRectangle rect; /* relative rect */
+ XRectangle *notch; /* relative notch rect */
+ void (*event[LASTEvent]) (BlitzTile *, XEvent *);
};
-struct BlitzLabel {
- XRectangle rect;
- Bool expand;
- BlitzWidget *next;
- void (*draw)(BlitzWidget *);
- void (*destroy)(BlitzWidget *);
- /* widget specific */
+struct BlitzInput {
+ Drawable drawable;
BlitzColor color;
BlitzAlign align;
BlitzFont font;
+ XRectangle rect; /* relative rect */
char *text;
-};
-
-union BlitzWidget {
- XRectangle rect;
- Bool expand;
- BlitzWidget *next;
- void (*draw)(BlitzWidget *);
- void (*destroy)(BlitzWidget *);
- BlitzLabel label;
- BlitzLayout layout;
+ void (*event[LASTEvent]) (BlitzInput *, XEvent *);
};
/* obsolete, will be replaced soon */
@@ -112,6 +83,7 @@ Blitz __blitz;
/* blitz.c */
void blitz_x11_init(Display *dpy);
+Bool blitz_x11_event(XEvent *ev);
/* color.c */
int blitz_loadcolor(BlitzColor *c, char *colstr);
@@ -120,18 +92,10 @@ int blitz_loadcolor(BlitzColor *c, char *colstr);
void blitz_drawlabel(BlitzDraw *d);
void blitz_drawborder(BlitzDraw *d);
-/* layout.c */
-BlitzLayout *blitz_create_layout(BlitzWin *win, BlitzWidget **w);
+/* tile.c */
+void blitz_drawlabel(BlitzDraw *d);
+void blitz_drawborder(BlitzDraw *d);
/* font.c */
unsigned int blitz_textwidth(BlitzFont *font, char *text);
void blitz_loadfont(BlitzFont *font, char *fontstr);
-
-/* widget.c */
-void blitz_add_widget(BlitzWidget **l, BlitzWidget *w);
-void blitz_rm_widget(BlitzWidget **l, BlitzWidget *w);
-
-/* window.c */
-BlitzWin *blitz_create_win(unsigned long mask, int x, int y, int w, int h);
-void blitz_resize_win(BlitzWin *win, int x, int y, int w, int h);
-void blitz_destroy_win(BlitzWin *win);
diff --git a/liblitz/layout.c b/liblitz/layout.c
@@ -1,57 +0,0 @@
-/*
- * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-
-#include <cext.h>
-#include <stdlib.h>
-
-#include "blitz.h"
-
-/*
- * Each layout can be a widget. A layout may consist of
- * columns or rows of widgets, or of columns and rows of widgets.
- * Rows are scaled left to right, the first widget with
- * expand == True takes the remaining space of the overall row.
- * Columns are scaled top to bottom, the first widget with
- * expand == True takes the remaining space of the overall column.
- */
-static void
-xscale(BlitzWidget *w)
-{
-
-}
-
-static void
-xdestroy(BlitzWidget *w)
-{
- BlitzLayout *l = BLITZLAYOUT(w);
- for(w = l->cols; w; w = w->next)
- w->destroy(w);
- for(w = l->rows; w; w = w->next)
- w->destroy(w);
-}
-
-static void
-xdraw(BlitzWidget *w)
-{
- BlitzLayout *l = BLITZLAYOUT(w);
- for(w = l->cols; w; w = w->next)
- w->draw(w);
- for(w = l->rows; w; w = w->next)
- w->draw(w);
-}
-
-BlitzLayout *
-blitz_create_layout(BlitzWin *win, BlitzWidget **w)
-{
- BlitzLayout *l;
- l = cext_emallocz(sizeof(BlitzLayout));
- l->win = win;
- l->cols = l->rows = nil;
- l->destroy = xdestroy;
- l->draw = xdraw;
- l->scale = xscale;
- blitz_add_widget(w, BLITZWIDGET(l));
- return l;
-}
diff --git a/liblitz/widget.c b/liblitz/widget.c
@@ -1,27 +0,0 @@
-/*
- * (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * See LICENSE file for license details.
- */
-
-#include <cext.h>
-#include <stdlib.h>
-
-#include "blitz.h"
-
-void
-blitz_add_widget(BlitzWidget **l, BlitzWidget *w)
-{
- BlitzWidget **wt;
- for(wt = l; *wt; wt = &(*wt)->next);
- w->next = nil;
- *wt = w;
-}
-
-void
-blitz_rm_widget(BlitzWidget **l, BlitzWidget *w)
-{
- BlitzWidget **wt;
- for(wt = l; *wt && *wt != w; wt = &(*wt)->next);
- cext_assert(*wt == w);
- *wt = w->next;
-}
diff --git a/liblitz/window.c b/liblitz/window.c
@@ -1,45 +0,0 @@
-/*
- * (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"
-
-BlitzWin *
-blitz_create_win(unsigned long mask, int x, int y, int w, int h)
-{
- BlitzWin *win = cext_emallocz(sizeof(BlitzWin));
- XSetWindowAttributes wa;
- wa.override_redirect = 1;
- wa.background_pixmap = ParentRelative;
- wa.event_mask = mask;
-
- win->drawable = XCreateWindow(__blitz.display, __blitz.root,
- x, y, w, h, 0, DefaultDepth(__blitz.display, __blitz.screen),
- CopyFromParent, DefaultVisual(__blitz.display, __blitz.screen),
- CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
- win->gc = XCreateGC(__blitz.display, win->drawable, 0, 0);
- blitz_resize_win(win, x, y, w, h);
-
- return win;
-}
-
-void
-blitz_resize_win(BlitzWin *win, int x, int y, int w, int h)
-{
- win->rect.x = x;
- win->rect.y = y;
- win->rect.width = w;
- win->rect.height = h;
- XMoveResizeWindow(__blitz.display, win->drawable, x, y, w, h);
-}
-
-void
-blitz_destroy_win(BlitzWin *win)
-{
- XFreeGC(__blitz.display, win->gc);
- XDestroyWindow(__blitz.display, win->drawable);
-}