finished libsl/drw integration
[dwm.git] / drw.h
1 /* See LICENSE file for copyright and license details. */
2
3 typedef struct {
4 unsigned long rgb;
5 } Clr;
6
7 typedef struct {
8 Cursor cursor;
9 } Cur;
10
11 typedef struct {
12 int ascent;
13 int descent;
14 unsigned int h;
15 XFontSet set;
16 XFontStruct *xfont;
17 } Fnt;
18
19 typedef struct {
20 Clr *fg;
21 Clr *bg;
22 Clr *border;
23 } Theme;
24
25 typedef struct {
26 unsigned int w, h;
27 Display *dpy;
28 int screen;
29 Window root;
30 Drawable drawable;
31 GC gc;
32 Theme *theme;
33 Fnt *font;
34 } Drw;
35
36 typedef struct {
37 unsigned int w;
38 unsigned int h;
39 } Extnts;
40
41 /* Drawable abstraction */
42 Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
43 void drw_resize(Drw *drw, unsigned int w, unsigned int h);
44 void drw_free(Drw *drw);
45
46 /* Fnt abstraction */
47 Fnt *drw_font_create(Display *dpy, const char *fontname);
48 void drw_font_free(Display *dpy, Fnt *font);
49 void drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *extnts);
50 unsigned int drw_font_getexts_width(Fnt *font, const char *text, unsigned int len);
51
52 /* Colour abstraction */
53 Clr *drw_clr_create(Drw *drw, const char *clrname);
54 void drw_clr_free(Clr *clr);
55
56 /* Cursor abstraction */
57 Cur *drw_cur_create(Drw *drw, int shape);
58 void drw_cur_free(Drw *drw, Cur *cursor);
59
60 /* Drawing context manipulation */
61 void drw_setfont(Drw *drw, Fnt *font);
62 void drw_settheme(Drw *drw, Theme *theme);
63
64 /* Drawing functions */
65 void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert);
66 void drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert);
67
68 /* Map functions */
69 void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);