2013-04-17 15:21:47 -04:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long rgb;
|
|
|
|
} Clr;
|
|
|
|
|
2013-06-16 09:20:29 -04:00
|
|
|
typedef struct {
|
|
|
|
Cursor cursor;
|
|
|
|
} Cur;
|
|
|
|
|
2013-04-17 15:21:47 -04:00
|
|
|
typedef struct {
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
unsigned int h;
|
|
|
|
XFontSet set;
|
|
|
|
XFontStruct *xfont;
|
|
|
|
} Fnt;
|
|
|
|
|
2013-06-16 09:20:29 -04:00
|
|
|
typedef struct {
|
|
|
|
Clr *fg;
|
|
|
|
Clr *bg;
|
|
|
|
Clr *border;
|
2013-06-19 13:35:33 -04:00
|
|
|
} ClrScheme;
|
2013-06-16 09:20:29 -04:00
|
|
|
|
2013-04-17 15:21:47 -04:00
|
|
|
typedef struct {
|
|
|
|
unsigned int w, h;
|
|
|
|
Display *dpy;
|
|
|
|
int screen;
|
2013-06-16 09:20:29 -04:00
|
|
|
Window root;
|
|
|
|
Drawable drawable;
|
2013-04-17 15:21:47 -04:00
|
|
|
GC gc;
|
2013-06-19 13:35:33 -04:00
|
|
|
ClrScheme *scheme;
|
2013-04-17 15:21:47 -04:00
|
|
|
Fnt *font;
|
|
|
|
} 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 */
|
2013-06-16 09:20:29 -04:00
|
|
|
Fnt *drw_font_create(Display *dpy, const char *fontname);
|
|
|
|
void drw_font_free(Display *dpy, Fnt *font);
|
|
|
|
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-17 15:21:47 -04:00
|
|
|
|
2013-06-16 09:20:29 -04:00
|
|
|
/* Colour abstraction */
|
2013-04-17 15:21:47 -04:00
|
|
|
Clr *drw_clr_create(Drw *drw, const char *clrname);
|
2013-06-16 09:20:29 -04: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-17 15:21:47 -04:00
|
|
|
|
|
|
|
/* Drawing context manipulation */
|
|
|
|
void drw_setfont(Drw *drw, Fnt *font);
|
2013-06-19 13:35:33 -04:00
|
|
|
void drw_setscheme(Drw *drw, ClrScheme *scheme);
|
2013-04-17 15:21:47 -04:00
|
|
|
|
|
|
|
/* Drawing functions */
|
2013-06-16 09:20:29 -04:00
|
|
|
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert);
|
|
|
|
void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
|
2013-04-17 15:21:47 -04:00
|
|
|
|
|
|
|
/* Map functions */
|
2013-06-16 09:20:29 -04:00
|
|
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|