all repos — dwm @ d456617f0eb93df0ec8eb81ff6e04ca988c09c60

fork of suckless dynamic window manager

draw.h (view raw)

 1/* See LICENSE file for copyright and license details. */
 2
 3typedef struct _DDC DDC;
 4
 5/* X11 types - begin */
 6typedef struct _XDraw Draw;
 7struct _XDraw {
 8	unsigned int w, h;
 9	Display *dpy;
10	Drawable drawable;
11	GC gc;
12	DDC *dc;
13};
14
15struct _XCol {
16	unsigned long rgb;
17};
18typedef struct _XCol Col;
19
20struct _XFont {
21	int ascent;
22	int descent;
23	unsigned int h, w;
24	XFontSet set;
25	XFontStruct *xfont;
26};
27typedef struct _XFont Fnt;
28/* X11 types - end */
29
30struct _DDC {
31	Draw *draw;
32	Col *fg;
33	Col *bg;
34	Fnt *font;
35	Bool fill;
36	DDC *next;
37};
38
39typedef struct {
40	unsigned int w;
41	unsigned int h;
42	int x;
43	int y;
44	int xOff;
45	int yOff;
46} TextExtents;
47
48/* Drawable abstraction */
49Draw *draw_create(Display *dpy, Window win, unsigned int w, unsigned int h);
50void draw_resize(Draw *draw, unsigned int w, unsigned int h);
51void draw_free(Draw *draw);
52
53/* Drawing context abstraction */
54DDC *dc_create(Draw *draw);
55void dc_free(DDC *dc);
56
57/* Fnt abstraction */
58Fnt *font_create(const char *fontname);
59void font_free(Fnt *font);
60
61/* Colour abstraction */
62Col *col_create(const char *colname);
63void col_free(Col *col);
64
65/* Drawing context manipulation */
66void dc_setfont(DDC *dc, Fnt *font);
67void dc_setfg(DDC *dc, Col *col);
68void dc_setbg(DDC *dc, Col *col);
69void dc_setfill(DDC *dc, Bool fill);
70
71/* Drawing functions */
72void dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h);
73void dc_drawtext(DDC *dc, int x, int y, const char *text);
74
75/* Map functions */
76void dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h);
77
78/* Text functions */
79void dc_getextents(DDC *dc, const char *text, TextExtents *extents);
80