2005-11-18 17:54:58 +02:00
|
|
|
/*
|
2006-01-20 16:20:24 +02:00
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 17:54:58 +02:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
2006-05-01 23:32:04 +02:00
|
|
|
#include <X11/Xlocale.h>
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-03-23 02:34:00 -08:00
|
|
|
#define BLITZ_FONT "fixed"
|
2006-05-19 20:14:06 +02:00
|
|
|
#define BLITZ_SELCOLORS "#ffffff #335577 #447799"
|
2006-03-23 02:34:00 -08:00
|
|
|
#define BLITZ_NORMCOLORS "#222222 #eeeeee #666666"
|
2005-11-18 17:54:58 +02:00
|
|
|
|
2006-06-13 11:21:06 +02:00
|
|
|
typedef struct Blitz Blitz;
|
|
|
|
typedef enum BlitzAlign BlitzAlign;
|
|
|
|
typedef struct BlitzColor BlitzColor;
|
|
|
|
typedef struct BlitzFont BlitzFont;
|
2006-06-22 11:03:42 +02:00
|
|
|
typedef struct BlitzBrush BlitzBrush;
|
2006-06-22 11:53:05 +02:00
|
|
|
typedef struct BlitzInput BlitzInput;
|
2006-06-13 11:21:06 +02:00
|
|
|
|
|
|
|
struct Blitz {
|
2006-06-12 15:20:03 +02:00
|
|
|
Display *display;
|
|
|
|
int screen;
|
|
|
|
Window root;
|
2006-06-13 11:21:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum BlitzAlign {
|
|
|
|
NORTH = 0x01,
|
|
|
|
EAST = 0x02,
|
|
|
|
SOUTH = 0x04,
|
|
|
|
WEST = 0x08,
|
|
|
|
NEAST = NORTH | EAST,
|
|
|
|
NWEST = NORTH | WEST,
|
|
|
|
SEAST = SOUTH | EAST,
|
|
|
|
SWEST = SOUTH | WEST,
|
|
|
|
CENTER = NEAST | SWEST
|
|
|
|
};
|
|
|
|
|
|
|
|
struct BlitzColor {
|
2005-12-05 00:45:59 +02:00
|
|
|
unsigned long bg;
|
|
|
|
unsigned long fg;
|
|
|
|
unsigned long border;
|
2006-06-19 10:28:37 +02:00
|
|
|
char colstr[24]; /* #RRGGBB #RRGGBB #RRGGBB */
|
2006-06-13 11:21:06 +02:00
|
|
|
};
|
2006-02-02 17:44:45 +02:00
|
|
|
|
2006-06-13 11:21:06 +02:00
|
|
|
struct BlitzFont {
|
2006-04-23 23:32:36 +02:00
|
|
|
XFontStruct *xfont;
|
2006-04-24 01:01:49 +02:00
|
|
|
XFontSet set;
|
2006-05-01 23:32:04 +02:00
|
|
|
int ascent;
|
|
|
|
int descent;
|
2006-06-22 12:20:22 +02:00
|
|
|
int rbearing;
|
|
|
|
int lbearing;
|
2006-06-19 10:28:37 +02:00
|
|
|
char *fontstr;
|
2006-06-13 11:21:06 +02:00
|
|
|
};
|
|
|
|
|
2006-06-22 11:03:42 +02:00
|
|
|
struct BlitzBrush {
|
|
|
|
Blitz *blitz;
|
2006-06-13 15:49:28 +02:00
|
|
|
Drawable drawable;
|
2006-06-14 18:42:47 +02:00
|
|
|
GC gc;
|
2006-06-23 11:34:10 +02:00
|
|
|
Bool border;
|
2006-06-13 15:03:46 +02:00
|
|
|
BlitzColor color;
|
2006-06-13 11:21:06 +02:00
|
|
|
BlitzAlign align;
|
2006-06-19 18:26:06 +02:00
|
|
|
BlitzFont *font;
|
2006-06-14 18:23:49 +02:00
|
|
|
XRectangle rect; /* relative rect */
|
2006-06-13 11:21:06 +02:00
|
|
|
};
|
2006-04-23 20:00:47 +02:00
|
|
|
|
2006-06-22 11:53:05 +02:00
|
|
|
struct BlitzInput {
|
2006-06-22 12:20:22 +02:00
|
|
|
Blitz *blitz;
|
2006-06-22 11:53:05 +02:00
|
|
|
char *text;
|
2006-06-23 10:47:07 +02:00
|
|
|
char *curstart;
|
|
|
|
char *curend;
|
2006-06-22 11:53:05 +02:00
|
|
|
unsigned int size;
|
2006-06-22 12:20:22 +02:00
|
|
|
Drawable drawable;
|
|
|
|
GC gc;
|
2006-06-23 10:47:07 +02:00
|
|
|
BlitzColor color;
|
2006-06-22 12:20:22 +02:00
|
|
|
BlitzFont *font;
|
|
|
|
XRectangle rect; /* relative rect */
|
2006-06-22 11:53:05 +02:00
|
|
|
};
|
|
|
|
|
2006-06-22 11:03:42 +02:00
|
|
|
/* brush.c */
|
2006-06-22 12:00:18 +02:00
|
|
|
void blitz_draw_label(BlitzBrush *b, char *text);
|
2006-06-22 11:03:42 +02:00
|
|
|
void blitz_draw_tile(BlitzBrush *b);
|
2006-06-13 17:27:01 +02:00
|
|
|
|
2006-06-22 14:26:55 +02:00
|
|
|
/* color.c */
|
|
|
|
int blitz_loadcolor(Blitz *blitz, BlitzColor *c);
|
|
|
|
|
2006-06-23 11:34:10 +02:00
|
|
|
/* draw.c */
|
2006-06-22 14:26:55 +02:00
|
|
|
void blitz_drawbg(Display *dpy, Drawable drawable, GC gc,
|
2006-06-23 11:34:10 +02:00
|
|
|
XRectangle rect, BlitzColor c, Bool border);
|
2006-06-22 14:26:55 +02:00
|
|
|
|
2006-06-12 15:20:03 +02:00
|
|
|
/* font.c */
|
|
|
|
unsigned int blitz_textwidth(BlitzFont *font, char *text);
|
2006-06-22 11:03:42 +02:00
|
|
|
void blitz_loadfont(Blitz *blitz, BlitzFont *font);
|
2006-06-22 14:26:55 +02:00
|
|
|
|
|
|
|
/* input.c */
|
|
|
|
void blitz_draw_input(BlitzInput *i);
|
2006-06-22 14:56:21 +02:00
|
|
|
char *blitz_charof(BlitzInput *i, int x, int y);
|