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