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