all repos — dwm @ aafeaf731701e528f4ae9d7c7432b3e92fee4392

fork of suckless dynamic window manager

draw.h (view raw)

 1/* See LICENSE file for copyright and license details. */
 2
 3struct _XCol {
 4	unsigned long rgb;
 5};
 6typedef struct _XCol Col;
 7
 8struct _XFont {
 9	int ascent;
10	int descent;
11	unsigned int h;
12	XFontSet set;
13	XFontStruct *xfont;
14};
15typedef struct _XFont Fnt;
16
17typedef struct _XDraw Draw;
18struct _XDraw {
19	unsigned int w, h;
20	Display *dpy;
21	int screen;
22	Window win;
23	Drawable drawable;
24	GC gc;
25	Col *fg;
26	Col *bg;
27	Fnt *font;
28};
29
30typedef struct {
31	unsigned int w;
32	unsigned int h;
33	int xOff;
34	int yOff;
35} TextExtents;
36
37/* Drawable abstraction */
38Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
39void draw_resize(Draw *draw, unsigned int w, unsigned int h);
40void draw_free(Draw *draw);
41
42/* Fnt abstraction */
43Fnt *draw_font_create(Draw *draw, const char *fontname);
44void draw_font_free(Draw *draw, Fnt *font);
45
46/* Colour abstraction */
47Col *draw_col_create(Draw *draw, const char *colname);
48void draw_col_free(Draw *draw, Col *col);
49
50/* Drawing context manipulation */
51void draw_setfont(Draw *draw, Fnt *font);
52void draw_setfg(Draw *draw, Col *col);
53void draw_setbg(Draw *draw, Col *col);
54
55/* Drawing functions */
56void draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h, Bool filled, Bool empty, Bool invert);
57void draw_text(Draw *draw, int x, int y, unsigned int w, unsigned int h, const char *text, Bool invert);
58
59/* Map functions */
60void draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h);
61
62/* Text functions */
63void draw_getextents(Draw *draw, const char *text, unsigned int len, TextExtents *extents);
64