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 dc_create(Draw *draw) {
40 DDC *dc = (DDC *)calloc(1, sizeof(DDC));
53 /* remove from dc list */
54 for(tdc = &dc->draw->dc; *tdc && *tdc != dc; tdc = &(*tdc)->next);
56 /* TODO: deallocate any resources of this dc, if needed */
61 font_create(const char *fontname) {
62 Fnt *font = (Fnt *)calloc(1, sizeof(Fnt));
63 /* TODO: allocate actual font */
68 font_free(Fnt *font) {
71 /* TODO: deallocate any font resources */
76 col_create(const char *colname) {
77 Col *col = (Col *)calloc(1, sizeof(Col));
78 /* TODO: allocate color */
86 /* TODO: deallocate any color resource */
91 dc_setfont(DDC *dc, Fnt *font) {
98 dc_setfg(DDC *dc, Col *col) {
105 dc_setbg(DDC *dc, Col *col) {
112 dc_setfill(DDC *dc, Bool fill) {
119 dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h) {
122 /* TODO: draw the rectangle */
126 dc_drawtext(DDC *dc, int x, int y, const char *text) {
129 /* TODO: draw the text */
133 dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h) {
136 /* TODO: map the dc contents in the region */
140 dc_getextents(DDC *dc, const char *text, TextExtents *extents) {
143 /* TODO: get extents */