2005-11-18 18:54:58 +03:00
|
|
|
/*
|
2006-01-20 17:20:24 +03:00
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 18:54:58 +03:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
2006-05-02 01:32:04 +04:00
|
|
|
#include <X11/Xlocale.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-03-23 13:34:00 +03:00
|
|
|
#define BLITZ_FONT "fixed"
|
2006-05-19 22:14:06 +04:00
|
|
|
#define BLITZ_SELCOLORS "#ffffff #335577 #447799"
|
2006-03-23 13:34:00 +03:00
|
|
|
#define BLITZ_NORMCOLORS "#222222 #eeeeee #666666"
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-06-13 13:21:06 +04:00
|
|
|
typedef struct Blitz Blitz;
|
|
|
|
typedef enum BlitzAlign BlitzAlign;
|
|
|
|
typedef struct BlitzColor BlitzColor;
|
|
|
|
typedef struct BlitzFont BlitzFont;
|
2006-06-22 13:03:42 +04:00
|
|
|
typedef struct BlitzBrush BlitzBrush;
|
2006-06-22 13:53:05 +04:00
|
|
|
typedef struct BlitzInput BlitzInput;
|
2006-06-13 13:21:06 +04:00
|
|
|
|
|
|
|
struct Blitz {
|
2006-07-03 20:41:14 +04:00
|
|
|
Display *dpy;
|
2006-06-12 17:20:03 +04:00
|
|
|
int screen;
|
|
|
|
Window root;
|
2006-06-13 13:21:06 +04: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 01:45:59 +03:00
|
|
|
unsigned long bg;
|
|
|
|
unsigned long fg;
|
|
|
|
unsigned long border;
|
2006-06-19 12:28:37 +04:00
|
|
|
char colstr[24]; /* #RRGGBB #RRGGBB #RRGGBB */
|
2006-06-13 13:21:06 +04:00
|
|
|
};
|
2006-02-02 18:44:45 +03:00
|
|
|
|
2006-06-13 13:21:06 +04:00
|
|
|
struct BlitzFont {
|
2006-04-24 01:32:36 +04:00
|
|
|
XFontStruct *xfont;
|
2006-04-24 03:01:49 +04:00
|
|
|
XFontSet set;
|
2006-05-02 01:32:04 +04:00
|
|
|
int ascent;
|
|
|
|
int descent;
|
2006-06-19 12:28:37 +04:00
|
|
|
char *fontstr;
|
2006-06-13 13:21:06 +04:00
|
|
|
};
|
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
struct BlitzBrush {
|
|
|
|
Blitz *blitz;
|
2006-06-13 17:49:28 +04:00
|
|
|
Drawable drawable;
|
2006-06-14 20:42:47 +04:00
|
|
|
GC gc;
|
2006-06-23 13:34:10 +04:00
|
|
|
Bool border;
|
2006-06-13 17:03:46 +04:00
|
|
|
BlitzColor color;
|
2006-06-13 13:21:06 +04:00
|
|
|
BlitzAlign align;
|
2006-06-19 20:26:06 +04:00
|
|
|
BlitzFont *font;
|
2006-06-14 20:23:49 +04:00
|
|
|
XRectangle rect; /* relative rect */
|
2006-06-13 13:21:06 +04:00
|
|
|
};
|
2006-04-23 22:00:47 +04:00
|
|
|
|
2006-06-22 13:53:05 +04:00
|
|
|
struct BlitzInput {
|
2006-06-22 14:20:22 +04:00
|
|
|
Blitz *blitz;
|
2006-06-22 13:53:05 +04:00
|
|
|
char *text;
|
2006-06-23 12:47:07 +04:00
|
|
|
char *curstart;
|
|
|
|
char *curend;
|
2006-06-22 13:53:05 +04:00
|
|
|
unsigned int size;
|
2006-07-03 20:41:14 +04:00
|
|
|
unsigned int len;
|
|
|
|
Bool drag;
|
2006-06-22 14:20:22 +04:00
|
|
|
Drawable drawable;
|
2006-07-03 20:41:14 +04:00
|
|
|
Window win;
|
2006-06-22 14:20:22 +04:00
|
|
|
GC gc;
|
2006-06-23 12:47:07 +04:00
|
|
|
BlitzColor color;
|
2006-06-22 14:20:22 +04:00
|
|
|
BlitzFont *font;
|
|
|
|
XRectangle rect; /* relative rect */
|
2006-06-22 13:53:05 +04:00
|
|
|
};
|
|
|
|
|
2006-06-22 13:03:42 +04:00
|
|
|
/* brush.c */
|
2006-06-22 14:00:18 +04:00
|
|
|
void blitz_draw_label(BlitzBrush *b, char *text);
|
2006-06-22 13:03:42 +04:00
|
|
|
void blitz_draw_tile(BlitzBrush *b);
|
2006-06-13 19:27:01 +04:00
|
|
|
|
2006-06-22 16:26:55 +04:00
|
|
|
/* color.c */
|
|
|
|
int blitz_loadcolor(Blitz *blitz, BlitzColor *c);
|
|
|
|
|
2006-06-23 13:34:10 +04:00
|
|
|
/* draw.c */
|
2006-06-22 16:26:55 +04:00
|
|
|
void blitz_drawbg(Display *dpy, Drawable drawable, GC gc,
|
2006-06-23 13:34:10 +04:00
|
|
|
XRectangle rect, BlitzColor c, Bool border);
|
2006-06-30 14:21:26 +04:00
|
|
|
void blitz_drawcursor(Display *dpy, Drawable drawable, GC gc,
|
|
|
|
int x, int y, unsigned int h, BlitzColor c);
|
2006-06-22 16:26:55 +04:00
|
|
|
|
2006-06-12 17:20:03 +04:00
|
|
|
/* font.c */
|
|
|
|
unsigned int blitz_textwidth(BlitzFont *font, char *text);
|
2006-06-29 18:47:26 +04:00
|
|
|
unsigned int blitz_textwidth_l(BlitzFont *font, char *text, unsigned int len);
|
2006-06-22 13:03:42 +04:00
|
|
|
void blitz_loadfont(Blitz *blitz, BlitzFont *font);
|
2006-06-22 16:26:55 +04:00
|
|
|
|
|
|
|
/* input.c */
|
|
|
|
void blitz_draw_input(BlitzInput *i);
|
2006-06-28 10:30:49 +04:00
|
|
|
/* blitz_b* functions return True on expose */
|
|
|
|
Bool blitz_bpress_input(BlitzInput *i, int x, int y);
|
|
|
|
Bool blitz_brelease_input(BlitzInput *i, int x, int y);
|
|
|
|
Bool blitz_bmotion_input(BlitzInput *i, int x, int y);
|
|
|
|
Bool blitz_ispointinrect(int x, int y, XRectangle * r);
|
2006-07-03 20:41:14 +04:00
|
|
|
void blitz_setinput(BlitzInput *i, char *text);
|
|
|
|
Bool blitz_kpress_input(BlitzInput *i, KeySym k, char *ks);
|