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-06-12 17:20:03 +04:00
|
|
|
Display *display;
|
|
|
|
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-22 14:20:22 +04:00
|
|
|
int rbearing;
|
|
|
|
int lbearing;
|
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-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;
|
|
|
|
char *selstart;
|
|
|
|
char *selend;
|
|
|
|
char *cursor;
|
|
|
|
unsigned int size;
|
2006-06-22 14:20:22 +04:00
|
|
|
Drawable drawable;
|
|
|
|
GC gc;
|
|
|
|
BlitzColor sel;
|
|
|
|
BlitzColor norm;
|
|
|
|
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);
|
|
|
|
|
|
|
|
void blitz_drawbg(Display *dpy, Drawable drawable, GC gc,
|
|
|
|
XRectangle rect, BlitzColor c);
|
|
|
|
|
2006-06-12 17:20:03 +04:00
|
|
|
/* font.c */
|
|
|
|
unsigned int blitz_textwidth(BlitzFont *font, char *text);
|
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-22 16:56:21 +04:00
|
|
|
char *blitz_charof(BlitzInput *i, int x, int y);
|