JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
continued with draw.c and draw.h implementation, now the integration begins
[dwm.git] / draw.h
1 /* See LICENSE file for copyright and license details. */
2
3 struct _XCol {
4         unsigned long rgb;
5 };
6 typedef struct _XCol Col;
7
8 struct _XFont {
9         int ascent;
10         int descent;
11         unsigned int h;
12         XFontSet set;
13         XFontStruct *xfont;
14 };
15 typedef struct _XFont Fnt;
16
17 typedef struct _XDraw Draw;
18 struct _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
30 typedef struct {
31         unsigned int w;
32         unsigned int h;
33         int xOff;
34         int yOff;
35 } TextExtents;
36
37 /* Drawable abstraction */
38 Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
39 void draw_resize(Draw *draw, unsigned int w, unsigned int h);
40 void draw_free(Draw *draw);
41
42 /* Fnt abstraction */
43 Fnt *draw_font_create(Draw *draw, const char *fontname);
44 void draw_font_free(Draw *draw, Fnt *font);
45
46 /* Colour abstraction */
47 Col *draw_col_create(Draw *draw, const char *colname);
48 void draw_col_free(Draw *draw, Col *col);
49
50 /* Drawing context manipulation */
51 void draw_setfont(Draw *draw, Fnt *font);
52 void draw_setfg(Draw *draw, Col *col);
53 void draw_setbg(Draw *draw, Col *col);
54
55 /* Drawing functions */
56 void draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h, Bool filled, Bool empty, Bool invert);
57 void draw_text(Draw *draw, int x, int y, unsigned int w, unsigned int h, const char *text, Bool invert);
58
59 /* Map functions */
60 void draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h);
61
62 /* Text functions */
63 void draw_getextents(Draw *draw, const char *text, unsigned int len, TextExtents *extents);
64