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