- XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
+ XFreeFont(draw->dpy, font->xfont);
+ free(font);
+}
+
+Col *
+draw_col_create(Draw *draw, const char *colname) {
+ Col *col = (Col *)calloc(1, sizeof(Col));
+ Colormap cmap = DefaultColormap(draw->dpy, draw->screen);
+ XColor color;
+
+ if(!XAllocNamedColor(draw->dpy, cmap, colname, &color, &color))
+ die("error, cannot allocate color '%s'\n", colname);
+ col->rgb = color.pixel;
+ return col;
+}
+
+void
+draw_col_free(Draw *draw, Col *col) {
+ if(!col)
+ return;
+ free(col);
+}
+
+void
+draw_setfont(Draw *draw, Fnt *font) {
+ if(!draw || !font)
+ return;
+ draw->font = font;
+}
+
+void
+draw_setfg(Draw *draw, Col *col) {
+ if(!draw || !col)
+ return;
+ draw->fg = col;
+}
+
+void
+draw_setbg(Draw *draw, Col *col) {
+ if(!draw || !col)
+ return;
+ draw->bg = col;
+}
+
+void
+draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
+ if(!draw)
+ return;
+ /* TODO: draw the rectangle */
+}
+
+void
+draw_text(Draw *draw, int x, int y, const char *text) {
+ if(!draw)
+ return;
+ /* TODO: draw the text */