diff options
author | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-07-23 07:21:24 +0000 |
---|---|---|
committer | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-07-23 07:21:24 +0000 |
commit | 659ce3daaaac43ed08190d121de71bf236e0718d (patch) | |
tree | 88c8c3faf5f8c9eb356cc19b566911e6f9883d77 /draw.c | |
parent | a3bf26d2fade3eaadba6f20349cba6db82ca756d (diff) | |
download | dzen-659ce3daaaac43ed08190d121de71bf236e0718d.tar.gz dzen-659ce3daaaac43ed08190d121de71bf236e0718d.zip |
added support for X bitmap icons
git-svn-id: http://dzen.googlecode.com/svn/trunk@141 f2baff5b-bf2c-0410-a398-912abdc3d8b2
Diffstat (limited to 'draw.c')
-rw-r--r-- | draw.c | 41 |
1 files changed, 33 insertions, 8 deletions
@@ -152,6 +152,9 @@ get_token(const char *line, int * t, char **tval) { void set_opts(int type, char * value, int reverse) { + unsigned int w, h, xh, yh; + Pixmap * bm; + switch(type) { case fg: reverse ? @@ -168,15 +171,15 @@ set_opts(int type, char * value, int reverse) { char * parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { + unsigned int bm_w, bm_h, bm_xh, bm_yh; int i, next_pos=0, j=0, px=0, py=0, xorig, h=0, tw, ow; char lbuf[MAX_LINE_LEN], *rbuf = NULL; int t=-1; char *tval=NULL; XGCValues gcv; - Drawable pm; + Drawable pm, bm; XRectangle r = { dzen.x, dzen.y, dzen.w, dzen.h}; - /* parse line and return the text without control commands*/ if(nodraw) { rbuf = emalloc(MAX_LINE_LEN); @@ -245,12 +248,23 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { strcat(rbuf, lbuf); } else { - if(t != -1 && tval) - set_opts(t, tval, reverse); + if(t != -1 && tval){ + if(t == icon) { + if((XReadBitmapFile(dzen.dpy, pm, tval, &bm_w, + &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess) + && ((h/2 + px + bm_w) < dzen.w)) { + XCopyPlane(dzen.dpy, bm, pm, dzen.tgc, + 0, 0, bm_w, bm_h, px, 0, 1); + px += bm_w; + } + } + else + set_opts(t, tval, reverse); + } /* check if text is longer than window's width */ ow = j; tw = textnw(lbuf, strlen(lbuf)); - while((tw + px) > (dzen.w - h)) { + while( ((tw + px) > (dzen.w - h)) && j>=0) { lbuf[--j] = '\0'; tw = textnw(lbuf, strlen(lbuf)); } @@ -289,12 +303,23 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) { strcat(rbuf, lbuf); } else { - if(t != -1 && tval) - set_opts(t, tval, reverse); + if(t != -1 && tval){ + if(t == icon) { + if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w, + &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess + && (h/2 + px + bm_w < dzen.w)) { + XCopyPlane(dzen.dpy, bm, pm, dzen.tgc, + 0, 0, bm_w, bm_h, px, 0, 1); + px += bm_w; + } + } + else + set_opts(t, tval, reverse); + } /* check if text is longer than window's width */ ow = j; tw = textnw(lbuf, strlen(lbuf)); - while((tw + px) > (dzen.w - h)) { + while( ((tw + px) > (dzen.w - h)) && j>=0) { lbuf[--j] = '\0'; tw = textnw(lbuf, strlen(lbuf)); } |