1 /* See LICENSE file for copyright and license details. */
8 draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h) {
9 Draw *draw = (Draw *)calloc(1, sizeof(Draw));
11 draw->screen = screen;
15 draw->drawable = XCreatePixmap(dpy, win, w, h, DefaultDepth(dpy, screen));
16 draw->gc = XCreateGC(dpy, win, 0, NULL);
17 XSetLineAttributes(dpy, draw->gc, 1, LineSolid, CapButt, JoinMiter);
22 draw_resize(Draw *draw, unsigned int w, unsigned int h) {
27 XFreePixmap(draw->dpy, draw->drawable);
28 draw->drawable = XCreatePixmap(draw->dpy, draw->win, w, h, DefaultDepth(draw->dpy, draw->screen));
32 draw_free(Draw *draw) {
33 XFreePixmap(draw->dpy, draw->drawable);
34 XFreeGC(draw->dpy, draw->gc);
39 font_create(const char *fontname) {
40 Fnt *font = (Fnt *)calloc(1, sizeof(Fnt));
41 /* TODO: allocate actual font */
46 font_free(Fnt *font) {
49 /* TODO: deallocate any font resources */
54 col_create(const char *colname) {
55 Col *col = (Col *)calloc(1, sizeof(Col));
56 /* TODO: allocate color */
64 /* TODO: deallocate any color resource */
69 draw_setfont(Draw *draw, Fnt *font) {
76 draw_setfg(Draw *draw, Col *col) {
83 draw_setbg(Draw *draw, Col *col) {
90 draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
93 /* TODO: draw the rectangle */
97 draw_text(Draw *draw, int x, int y, const char *text) {
100 /* TODO: draw the text */
104 draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
107 /* TODO: map the draw contents in the region */
111 draw_getextents(Draw *draw, const char *text, TextExtents *extents) {
112 if(!draw || !extents)
114 /* TODO: get extents */