2013-04-18 02:21:47 +07:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
2015-03-06 11:26:11 +07:00
|
|
|
#define DRW_FONT_CACHE_SIZE 32
|
2013-04-18 02:21:47 +07:00
|
|
|
|
|
|
|
typedef struct {
|
2015-03-06 11:26:11 +07:00
|
|
|
unsigned long pix;
|
|
|
|
XftColor rgb;
|
2013-04-18 02:21:47 +07:00
|
|
|
} Clr;
|
|
|
|
|
2013-06-16 20:20:29 +07:00
|
|
|
typedef struct {
|
|
|
|
Cursor cursor;
|
|
|
|
} Cur;
|
|
|
|
|
2013-04-18 02:21:47 +07:00
|
|
|
typedef struct {
|
2015-03-06 11:26:11 +07:00
|
|
|
Display *dpy;
|
2013-04-18 02:21:47 +07:00
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
unsigned int h;
|
2015-03-06 11:26:11 +07:00
|
|
|
XftFont *xfont;
|
|
|
|
FcPattern *pattern;
|
2013-04-18 02:21:47 +07:00
|
|
|
} Fnt;
|
|
|
|
|
2013-06-16 20:20:29 +07:00
|
|
|
typedef struct {
|
|
|
|
Clr *fg;
|
|
|
|
Clr *bg;
|
|
|
|
Clr *border;
|
2013-06-20 00:35:33 +07:00
|
|
|
} ClrScheme;
|
2013-06-16 20:20:29 +07:00
|
|
|
|
2013-04-18 02:21:47 +07:00
|
|
|
typedef struct {
|
|
|
|
unsigned int w, h;
|
|
|
|
Display *dpy;
|
|
|
|
int screen;
|
2013-06-16 20:20:29 +07:00
|
|
|
Window root;
|
|
|
|
Drawable drawable;
|
2013-04-18 02:21:47 +07:00
|
|
|
GC gc;
|
2013-06-20 00:35:33 +07:00
|
|
|
ClrScheme *scheme;
|
2015-03-06 11:26:11 +07:00
|
|
|
size_t fontcount;
|
|
|
|
Fnt *fonts[DRW_FONT_CACHE_SIZE];
|
2013-04-18 02:21:47 +07:00
|
|
|
} Drw;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int w;
|
|
|
|
unsigned int h;
|
|
|
|
} Extnts;
|
|
|
|
|
|
|
|
/* Drawable abstraction */
|
|
|
|
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
|
|
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
|
|
|
void drw_free(Drw *drw);
|
|
|
|
|
|
|
|
/* Fnt abstraction */
|
2015-03-06 11:26:11 +07:00
|
|
|
Fnt *drw_font_create(Drw *drw, const char *fontname);
|
|
|
|
void drw_load_fonts(Drw* drw, const char *fonts[], size_t fontcount);
|
|
|
|
void drw_font_free(Fnt *font);
|
2013-06-16 20:20:29 +07:00
|
|
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *extnts);
|
|
|
|
unsigned int drw_font_getexts_width(Fnt *font, const char *text, unsigned int len);
|
2013-04-18 02:21:47 +07:00
|
|
|
|
2013-06-16 20:20:29 +07:00
|
|
|
/* Colour abstraction */
|
2013-04-18 02:21:47 +07:00
|
|
|
Clr *drw_clr_create(Drw *drw, const char *clrname);
|
2013-06-16 20:20:29 +07:00
|
|
|
void drw_clr_free(Clr *clr);
|
|
|
|
|
|
|
|
/* Cursor abstraction */
|
|
|
|
Cur *drw_cur_create(Drw *drw, int shape);
|
|
|
|
void drw_cur_free(Drw *drw, Cur *cursor);
|
2013-04-18 02:21:47 +07:00
|
|
|
|
|
|
|
/* Drawing context manipulation */
|
|
|
|
void drw_setfont(Drw *drw, Fnt *font);
|
2013-06-20 00:35:33 +07:00
|
|
|
void drw_setscheme(Drw *drw, ClrScheme *scheme);
|
2013-04-18 02:21:47 +07:00
|
|
|
|
|
|
|
/* Drawing functions */
|
2013-06-16 20:20:29 +07:00
|
|
|
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert);
|
2015-03-06 11:26:11 +07:00
|
|
|
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
|
2013-04-18 02:21:47 +07:00
|
|
|
|
|
|
|
/* Map functions */
|
2013-06-16 20:20:29 +07:00
|
|
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|