sent/drw.h

65 lines
1.6 KiB
C
Raw Normal View History

2015-04-05 13:48:47 +00:00
/* See LICENSE file for copyright and license details. */
#define DRW_FONT_CACHE_SIZE 32
typedef struct {
Cursor cursor;
} Cur;
typedef struct {
Display *dpy;
int ascent;
int descent;
unsigned int h;
XftFont *xfont;
FcPattern *pattern;
} Fnt;
typedef struct {
2015-04-10 21:12:50 +00:00
struct {
unsigned long pix;
XftColor rgb;
} fg, bg;
} Scm;
2015-04-05 13:48:47 +00:00
typedef struct {
unsigned int w, h;
Display *dpy;
int screen;
Window root;
Drawable drawable;
GC gc;
2015-04-10 21:12:50 +00:00
Scm *scheme;
2015-04-05 13:48:47 +00:00
size_t fontcount;
Fnt *fonts[DRW_FONT_CACHE_SIZE];
} Drw;
/* 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);
2015-04-08 19:13:45 +00:00
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
2015-04-05 13:48:47 +00:00
2015-04-10 21:12:50 +00:00
/* Colorscheme abstraction */
Scm *drw_scm_create(Drw *drw, const char *fgname, const char *bgname);
void drw_scm_free(Scm *scm);
2015-04-05 13:48:47 +00:00
/* Cursor abstraction */
Cur *drw_cur_create(Drw *drw, int shape);
void drw_cur_free(Drw *drw, Cur *cursor);
/* Drawing context manipulation */
void drw_setfont(Drw *drw, Fnt *font);
2015-04-10 21:12:50 +00:00
void drw_setscheme(Drw *drw, Scm *scm);
2015-04-05 13:48:47 +00:00
/* Drawing functions */
2015-04-12 20:56:56 +00:00
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
2015-04-05 13:48:47 +00:00
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
/* Map functions */
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);