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