all repos — dwm @ 42cf1c7d8f94e1c51a71761ab24414c2f49dac26

fork of suckless dynamic window manager

drw.h (view raw)

 1/* See LICENSE file for copyright and license details. */
 2#define DRW_FONT_CACHE_SIZE 32
 3
 4typedef struct {
 5	unsigned long pix;
 6	XftColor rgb;
 7} Clr;
 8
 9typedef struct {
10	Cursor cursor;
11} Cur;
12
13typedef struct {
14	Display *dpy;
15	int ascent;
16	int descent;
17	unsigned int h;
18	XftFont *xfont;
19	FcPattern *pattern;
20} Fnt;
21
22typedef struct {
23	Clr *fg;
24	Clr *bg;
25	Clr *border;
26} ClrScheme;
27
28typedef struct {
29	unsigned int w, h;
30	Display *dpy;
31	int screen;
32	Window root;
33	Drawable drawable;
34	GC gc;
35	ClrScheme *scheme;
36	size_t fontcount;
37	Fnt *fonts[DRW_FONT_CACHE_SIZE];
38} Drw;
39
40typedef struct {
41	unsigned int w;
42	unsigned int h;
43} Extnts;
44
45/* Drawable abstraction */
46Drw *drw_create(Display *, int, Window, unsigned int, unsigned int);
47void drw_resize(Drw *, unsigned int, unsigned int);
48void drw_free(Drw *);
49
50/* Fnt abstraction */
51Fnt *drw_font_create(Drw *, const char *);
52void drw_load_fonts(Drw *, const char *[], size_t);
53void drw_font_free(Fnt *);
54void drw_font_getexts(Fnt *, const char *, unsigned int, Extnts *);
55unsigned int drw_font_getexts_width(Fnt *, const char *, unsigned int);
56
57/* Colour abstraction */
58Clr *drw_clr_create(Drw *, const char *);
59void drw_clr_free(Clr *);
60
61/* Cursor abstraction */
62Cur *drw_cur_create(Drw *, int);
63void drw_cur_free(Drw *, Cur *);
64
65/* Drawing context manipulation */
66void drw_setfont(Drw *, Fnt *);
67void drw_setscheme(Drw *, ClrScheme *);
68
69/* Drawing functions */
70void drw_rect(Drw *, int, int, unsigned int, unsigned int, int, int, int);
71int drw_text(Drw *, int, int, unsigned int, unsigned int, const char *, int);
72
73/* Map functions */
74void drw_map(Drw *, Window, int, int, unsigned int, unsigned int);