diff options
Diffstat (limited to 'generic/Icon.c')
-rw-r--r-- | generic/Icon.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/generic/Icon.c b/generic/Icon.c index ea4ecfd..c9635a1 100644 --- a/generic/Icon.c +++ b/generic/Icon.c @@ -56,6 +56,7 @@ typedef struct _IconItemStruct { ZnAnchor connection_anchor; Pixmap mask; /* Used only if the image is *NOT* specified */ ZnColor color; /* Used with the mask */ + int alpha; /* Private data */ ZnPoint pos_dev; @@ -64,6 +65,8 @@ typedef struct _IconItemStruct { static ZnAttrConfig icon_attrs[] = { + { ZN_CONFIG_UINT, "-alpha", NULL, + Tk_Offset(IconItemStruct, alpha), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_ANCHOR, "-anchor", NULL, Tk_Offset(IconItemStruct, anchor), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_COLOR, "-color", NULL, @@ -154,7 +157,8 @@ Init(Item item, icon->connection_anchor = ZnAnchorSW; icon->mask = ZnUnspecifiedPattern; icon->color = ZnGetColorByValue(wi->win, wi->fore_color); - + icon->alpha = 255; + return ZN_OK; } @@ -526,6 +530,41 @@ Draw(Item item) /* ********************************************************************************** * + * Render -- + * + ********************************************************************************** + */ +static void +Render(Item item) +{ + WidgetInfo *wi = item->wi; + IconItem icon = (IconItem) item; + + if (icon->image != ZnUnspecifiedImage) { + ArtPixBuf *pixbuf; + pixbuf = GetImagePixbuf(wi->win, icon->image_name, icon->image); + rgb_image(wi->buf.buf, wi->buf.ox, wi->buf.oy, + wi->buf.cx, wi->buf.cy, wi->buf.rowstride, + pixbuf, icon->pos_dev.x, icon->pos_dev.y, icon->alpha); + } + else if (icon->mask != ZnUnspecifiedPattern) { + BitmapBits *bitmap = GetBitmapMask(wi->dpy, icon->mask); + art_u32 rgba; + + rgba = (((icon->color->red & 0xff00) << 16) | + ((icon->color->green & 0xff00) << 8) | + (icon->color->blue & 0xff00) | (icon->alpha & 0xff)); + rgb_bitmap(wi->buf.buf, wi->buf.ox, wi->buf.oy, + wi->buf.cx, wi->buf.cy, wi->buf.rowstride, + bitmap->pixels, icon->pos_dev.x, icon->pos_dev.y, + bitmap->width, bitmap->height, bitmap->rowstride, rgba); + } +} + + +/* + ********************************************************************************** + * * IsSensitive -- * ********************************************************************************** @@ -572,7 +611,7 @@ Pick(Item item, * vicinity. */ if (dist <= 0.0) { - XImage *bitmap=NULL; + BitmapBits *bitmap=NULL; ImageBits *im_bits; ZnPoint dp; @@ -586,7 +625,7 @@ Pick(Item item, goto out_pick; } im_bits = GetImageBits(wi->win, icon->image_name, icon->image); - bitmap = im_bits->mask; + bitmap = im_bits->b_bits; } else if (icon->mask != ZnUnspecifiedPattern) { Tk_SizeOfBitmap(wi->dpy, icon->mask, &width, &height); @@ -596,10 +635,10 @@ Pick(Item item, } bitmap = GetBitmapMask(wi->dpy, icon->mask); } - if (bitmap != ZnUnspecifiedPattern) { - /*printf("dpx=%g, dpy=%g, width=%d, height=%d, pixel=%ld\n", dp.x, dp.y, - width, height, XGetPixel(bitmap, (int) dp.x, (int) dp.y));*/ - if (! XGetPixel(bitmap, (int) dp.x, (int) dp.y)) { + if (bitmap != NULL) { + int x = (int) dp.x; + int y = (int) dp.y; + if (! GetBitmapPixel(bitmap, x, y)) { dist = off_dist; } } @@ -767,6 +806,7 @@ static ItemClassStruct ICON_ITEM_CLASS = { ComputeCoordinates, ToArea, Draw, + Render, IsSensitive, Pick, NULL, /* PickVertex */ |