dwm-nest/drw.h

75 lines
1.8 KiB
C
Raw Normal View History

2013-04-17 19:21:47 +00:00
/* See LICENSE file for copyright and license details. */
#define DRW_FONT_CACHE_SIZE 32
2013-04-17 19:21:47 +00:00
typedef struct {
unsigned long pix;
XftColor rgb;
2013-04-17 19:21:47 +00:00
} Clr;
2013-06-16 13:20:29 +00:00
typedef struct {
Cursor cursor;
} Cur;
2013-04-17 19:21:47 +00:00
typedef struct {
Display *dpy;
2013-04-17 19:21:47 +00:00
int ascent;
int descent;
unsigned int h;
XftFont *xfont;
FcPattern *pattern;
2013-04-17 19:21:47 +00:00
} Fnt;
2013-06-16 13:20:29 +00:00
typedef struct {
Clr *fg;
Clr *bg;
Clr *border;
} ClrScheme;
2013-06-16 13:20:29 +00:00
2013-04-17 19:21:47 +00:00
typedef struct {
unsigned int w, h;
Display *dpy;
int screen;
2013-06-16 13:20:29 +00:00
Window root;
Drawable drawable;
2013-04-17 19:21:47 +00:00
GC gc;
ClrScheme *scheme;
size_t fontcount;
Fnt *fonts[DRW_FONT_CACHE_SIZE];
2013-04-17 19:21:47 +00: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 */
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 13:20:29 +00: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-17 19:21:47 +00:00
2013-06-16 13:20:29 +00:00
/* Colour abstraction */
2013-04-17 19:21:47 +00:00
Clr *drw_clr_create(Drw *drw, const char *clrname);
2013-06-16 13:20:29 +00: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 19:21:47 +00:00
/* Drawing context manipulation */
void drw_setfont(Drw *drw, Fnt *font);
void drw_setscheme(Drw *drw, ClrScheme *scheme);
2013-04-17 19:21:47 +00:00
/* Drawing functions */
2013-06-16 13:20:29 +00:00
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert);
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
2013-04-17 19:21:47 +00:00
/* Map functions */
2013-06-16 13:20:29 +00:00
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);