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