summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranselm@garbe.us <unknown>2012-11-18 17:52:42 +0100
committeranselm@garbe.us <unknown>2012-11-18 17:52:42 +0100
commitc0ba635c50dc53f06e4fc96392415b3d19b25826 (patch)
tree4132d1d70ac788936b8619f5b3af8c0f78907b43
parentcontinued, distinction of Draw and DDC is bad, needs to be merged (diff)
downloaddwm-c0ba635c50dc53f06e4fc96392415b3d19b25826.tar.gz
dwm-c0ba635c50dc53f06e4fc96392415b3d19b25826.zip
removed DDC, all is Draw-dependent
Diffstat (limited to '')
-rw-r--r--draw.c65
-rw-r--r--draw.h57
2 files changed, 40 insertions, 82 deletions
diff --git a/draw.c b/draw.c
index df5aeec..01436ea 100644
--- a/draw.c
+++ b/draw.c
@@ -35,28 +35,6 @@ draw_free(Draw *draw) {
35 free(draw); 35 free(draw);
36} 36}
37 37
38DDC *
39dc_create(Draw *draw) {
40 DDC *dc = (DDC *)calloc(1, sizeof(DDC));
41 dc->draw = draw;
42 dc->next = draw->dc;
43 draw->dc = dc;
44 return dc;
45}
46
47void
48dc_free(DDC *dc) {
49 DDC **tdc;
50
51 if(!dc)
52 return;
53 /* remove from dc list */
54 for(tdc = &dc->draw->dc; *tdc && *tdc != dc; tdc = &(*tdc)->next);
55 *tdc = dc->next;
56 /* TODO: deallocate any resources of this dc, if needed */
57 free(dc);
58}
59
60Fnt * 38Fnt *
61font_create(const char *fontname) { 39font_create(const char *fontname) {
62 Fnt *font = (Fnt *)calloc(1, sizeof(Fnt)); 40 Fnt *font = (Fnt *)calloc(1, sizeof(Fnt));
@@ -88,57 +66,50 @@ col_free(Col *col) {
88} 66}
89 67
90void 68void
91dc_setfont(DDC *dc, Fnt *font) { 69draw_setfont(Draw *draw, Fnt *font) {
92 if(!dc || !font) 70 if(!draw || !font)
93 return; 71 return;
94 dc->font = font; 72 draw->font = font;
95} 73}
96 74
97void 75void
98dc_setfg(DDC *dc, Col *col) { 76draw_setfg(Draw *draw, Col *col) {
99 if(!dc || !col) 77 if(!draw || !col)
100 return; 78 return;
101 dc->fg = col; 79 draw->fg = col;
102} 80}
103 81
104void 82void
105dc_setbg(DDC *dc, Col *col) { 83draw_setbg(Draw *draw, Col *col) {
106 if(!dc || !col) 84 if(!draw || !col)
107 return; 85 return;
108 dc->bg = col; 86 draw->bg = col;
109} 87}
110 88
111void 89void
112dc_setfill(DDC *dc, Bool fill) { 90draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
113 if(!dc) 91 if(!draw)
114 return;
115 dc->fill = fill;
116}
117
118void
119dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h) {
120 if(!dc)
121 return; 92 return;
122 /* TODO: draw the rectangle */ 93 /* TODO: draw the rectangle */
123} 94}
124 95
125void 96void
126dc_drawtext(DDC *dc, int x, int y, const char *text) { 97draw_text(Draw *draw, int x, int y, const char *text) {
127 if(!dc) 98 if(!draw)
128 return; 99 return;
129 /* TODO: draw the text */ 100 /* TODO: draw the text */
130} 101}
131 102
132void 103void
133dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h) { 104draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h) {
134 if(!dc) 105 if(!draw)
135 return; 106 return;
136 /* TODO: map the dc contents in the region */ 107 /* TODO: map the draw contents in the region */
137} 108}
138 109
139void 110void
140dc_getextents(DDC *dc, const char *text, TextExtents *extents) { 111draw_getextents(Draw *draw, const char *text, TextExtents *extents) {
141 if(!dc || !extents) 112 if(!draw || !extents)
142 return; 113 return;
143 /* TODO: get extents */ 114 /* TODO: get extents */
144} 115}
diff --git a/draw.h b/draw.h
index 95242ea..d1a2f37 100644
--- a/draw.h
+++ b/draw.h
@@ -1,19 +1,5 @@
1/* See LICENSE file for copyright and license details. */ 1/* See LICENSE file for copyright and license details. */
2 2
3typedef struct _DDC DDC;
4
5/* X11 types - begin */
6typedef struct _XDraw Draw;
7struct _XDraw {
8 unsigned int w, h;
9 Display *dpy;
10 int screen;
11 Window win;
12 Drawable drawable;
13 GC gc;
14 DDC *dc;
15};
16
17struct _XCol { 3struct _XCol {
18 unsigned long rgb; 4 unsigned long rgb;
19}; 5};
@@ -29,15 +15,6 @@ struct _XFont {
29typedef struct _XFont Fnt; 15typedef struct _XFont Fnt;
30/* X11 types - end */ 16/* X11 types - end */
31 17
32struct _DDC {
33 Draw *draw;
34 Col *fg;
35 Col *bg;
36 Fnt *font;
37 Bool fill;
38 DDC *next;
39};
40
41typedef struct { 18typedef struct {
42 unsigned int w; 19 unsigned int w;
43 unsigned int h; 20 unsigned int h;
@@ -47,15 +24,26 @@ typedef struct {
47 int yOff; 24 int yOff;
48} TextExtents; 25} TextExtents;
49 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
50/* Drawable abstraction */ 42/* Drawable abstraction */
51Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h); 43Draw *draw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
52void draw_resize(Draw *draw, unsigned int w, unsigned int h); 44void draw_resize(Draw *draw, unsigned int w, unsigned int h);
53void draw_free(Draw *draw); 45void draw_free(Draw *draw);
54 46
55/* Drawing context abstraction */
56DDC *dc_create(Draw *draw);
57void dc_free(DDC *dc);
58
59/* Fnt abstraction */ 47/* Fnt abstraction */
60Fnt *font_create(const char *fontname); 48Fnt *font_create(const char *fontname);
61void font_free(Fnt *font); 49void font_free(Fnt *font);
@@ -65,18 +53,17 @@ Col *col_create(const char *colname);
65void col_free(Col *col); 53void col_free(Col *col);
66 54
67/* Drawing context manipulation */ 55/* Drawing context manipulation */
68void dc_setfont(DDC *dc, Fnt *font); 56void draw_setfont(Draw *draw, Fnt *font);
69void dc_setfg(DDC *dc, Col *col); 57void draw_setfg(Draw *draw, Col *col);
70void dc_setbg(DDC *dc, Col *col); 58void draw_setbg(Draw *draw, Col *col);
71void dc_setfill(DDC *dc, Bool fill);
72 59
73/* Drawing functions */ 60/* Drawing functions */
74void dc_drawrect(DDC *dc, int x, int y, unsigned int w, unsigned int h); 61void draw_rect(Draw *draw, int x, int y, unsigned int w, unsigned int h);
75void dc_drawtext(DDC *dc, int x, int y, const char *text); 62void draw_text(Draw *draw, int x, int y, const char *text);
76 63
77/* Map functions */ 64/* Map functions */
78void dc_map(DDC *dc, int x, int y, unsigned int w, unsigned int h); 65void draw_map(Draw *draw, int x, int y, unsigned int w, unsigned int h);
79 66
80/* Text functions */ 67/* Text functions */
81void dc_getextents(DDC *dc, const char *text, TextExtents *extents); 68void draw_getextents(Draw *draw, const char *text, TextExtents *extents);
82 69