Xinqi Bao's Git

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