aboutsummaryrefslogtreecommitdiff
path: root/generic/Icon.c
diff options
context:
space:
mode:
authorlecoanet2002-05-27 15:06:53 +0000
committerlecoanet2002-05-27 15:06:53 +0000
commit41ab96778d770512c9f6046c3f64f8d15f2ff8f0 (patch)
tree0b96969da69796df5ebd4d6f13ebbeb94f2a9df2 /generic/Icon.c
parent5b9d2fa3a163fb43731dfa7d991fcb5e9d2a8e61 (diff)
downloadtkzinc-41ab96778d770512c9f6046c3f64f8d15f2ff8f0.zip
tkzinc-41ab96778d770512c9f6046c3f64f8d15f2ff8f0.tar.gz
tkzinc-41ab96778d770512c9f6046c3f64f8d15f2ff8f0.tar.bz2
tkzinc-41ab96778d770512c9f6046c3f64f8d15f2ff8f0.tar.xz
L'item Icon ne poss�de plus qu'un attribut -image/-mask. Cependant il
est toujours possible de positionner cet attribut soit par -image soit par -mask. La reconnaissance bitmap/image est automatique.
Diffstat (limited to 'generic/Icon.c')
-rw-r--r--generic/Icon.c76
1 files changed, 21 insertions, 55 deletions
diff --git a/generic/Icon.c b/generic/Icon.c
index 37dc235..d9219f6 100644
--- a/generic/Icon.c
+++ b/generic/Icon.c
@@ -54,8 +54,7 @@ typedef struct _IconItemStruct {
ZnImage image;
ZnAnchor anchor;
ZnAnchor connection_anchor;
- ZnImage mask; /* Used only if the image is *NOT* specified */
- ZnGradient *color; /* Used only with the mask (in GLX alpha part
+ ZnGradient *color; /* Used only if the image is a bitmap (in GLX alpha part
* is always meaningful). */
/* Private data */
@@ -85,7 +84,7 @@ static ZnAttrConfig icon_attrs[] = {
{ ZN_CONFIG_IMAGE, "-image", NULL,
Tk_Offset(IconItemStruct, image), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BITMAP, "-mask", NULL,
- Tk_Offset(IconItemStruct, mask), 0, ZN_DRAW_FLAG|ZN_REPICK_FLAG, False },
+ Tk_Offset(IconItemStruct, image), 0, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_POINT, "-position", NULL, Tk_Offset(IconItemStruct, pos), 0,
ZN_COORDS_FLAG, False},
{ ZN_CONFIG_PRI, "-priority", NULL,
@@ -132,7 +131,6 @@ Init(Item item,
icon->image = ZnUnspecifiedImage;
icon->anchor = ZnAnchorNW;
icon->connection_anchor = ZnAnchorSW;
- icon->mask = ZnUnspecifiedImage;
icon->color = ZnGetGradientByValue(wi->fore_color);
return ZN_OK;
@@ -154,9 +152,6 @@ Clone(Item item)
if (icon->image != ZnUnspecifiedImage) {
icon->image = ZnGetImageByValue(icon->image);
}
- if (icon->mask != ZnUnspecifiedImage) {
- icon->mask = ZnGetImageByValue(icon->mask);
- }
icon->color = ZnGetGradientByValue(icon->color);
}
@@ -177,10 +172,6 @@ Destroy(Item item)
ZnFreeImage(icon->image);
icon->image = ZnUnspecifiedImage;
}
- if (icon->mask != ZnUnspecifiedImage) {
- ZnFreeImage(icon->mask);
- icon->mask = ZnUnspecifiedImage;
- }
ZnFreeGradient(icon->color);
}
@@ -263,19 +254,15 @@ ComputeCoordinates(Item item,
ResetBBox(&item->item_bounding_box);
/*
- * If there is no image and no mask then nothing to show.
+ * If there is no image then nothing to show.
*/
- if (icon->image == ZnUnspecifiedImage &&
- icon->mask == ZnUnspecifiedImage) {
+ if (icon->image == ZnUnspecifiedImage) {
return;
}
if (icon->image != ZnUnspecifiedImage) {
ZnSizeOfImage(icon->image, &width, &height);
}
- else {
- ZnSizeOfImage(icon->mask, &width, &height);
- }
/*
* The connected item support anchors, this is checked by
@@ -334,9 +321,6 @@ ToArea(Item item,
if (icon->image != ZnUnspecifiedImage) {
ZnSizeOfImage(icon->image, &w, &h);
}
- else if (icon->mask != ZnUnspecifiedImage) {
- ZnSizeOfImage(icon->mask, &w, &h);
- }
box.corner.x = box.orig.x + w;
box.corner.y = box.orig.y + h;
@@ -364,7 +348,15 @@ Draw(Item item)
ZnBool simple;
Pixmap pixmap, mask_pmap;
- if (icon->image != ZnUnspecifiedImage) {
+ if (icon->image == ZnUnspecifiedImage) {
+ return;
+ }
+
+ ZnSizeOfImage(icon->image, &w, &h);
+ box.orig = icon->pos_dev;
+ box.corner.x = icon->pos_dev.x + w;
+ box.corner.y = icon->pos_dev.y + h;
+ if (!ZnImageIsBitmap(icon->image)) {
/*
* Added the case of a rectangular aligned clipping and the
* simple case of the damaged area clip. These are done here
@@ -377,10 +369,6 @@ Draw(Item item)
* using the image mask and the current clip and use this
* bitmap as the current clip.
*/
- ZnSizeOfImage(icon->image, &w, &h);
- box.orig = icon->pos_dev;
- box.corner.x = icon->pos_dev.x + w;
- box.corner.y = icon->pos_dev.y + h;
IntersectBBox(&box, &wi->damaged_area, &inter);
box = inter;
ZnCurrentClip(wi, &clip_region, NULL, &simple);
@@ -435,12 +423,8 @@ Draw(Item item)
XFreePixmap(wi->dpy, mask_pmap);
}
}
- else if (icon->mask != ZnUnspecifiedImage) {
- ZnSizeOfImage(icon->mask, &w, &h);
- pixmap = ZnImagePixmap(icon->mask, NULL);
- box.orig = icon->pos_dev;
- box.corner.x = icon->pos_dev.x + w;
- box.corner.y = icon->pos_dev.y + h;
+ else {
+ pixmap = ZnImagePixmap(icon->image, NULL);
ZnCurrentClip(wi, NULL, &clip_box, &simple);
if (simple) {
IntersectBBox(&box, clip_box, &inter);
@@ -475,10 +459,8 @@ Render(Item item)
IconItem icon = (IconItem) item;
if (icon->image != ZnUnspecifiedImage) {
- ZnRenderImage(wi, icon->image, icon->color, &icon->pos_dev, False);
- }
- else if (icon->mask != ZnUnspecifiedImage) {
- ZnRenderImage(wi, icon->mask, icon->color, &icon->pos_dev, True);
+ ZnRenderImage(wi, icon->image, icon->color, &icon->pos_dev,
+ ZnImageIsBitmap(icon->image));
}
#endif
}
@@ -550,13 +532,6 @@ Pick(Item item,
return off_dist;
}
}
- else if (icon->mask != ZnUnspecifiedImage) {
- bpixels = ZnImagePattern(icon->mask, &stride);
- ZnSizeOfImage(icon->mask, &w, &h);
- if ((dp.x >= w) || (dp.y >= h)) {
- return off_dist;
- }
- }
else {
return dist;
}
@@ -603,18 +578,12 @@ GetAnchor(Item item,
IconItem icon = (IconItem) item;
int w=0, h=0;
- if ((icon->image != ZnUnspecifiedImage) ||
- (icon->mask != ZnUnspecifiedImage)) {
- if (icon->image != ZnUnspecifiedImage) {
- ZnSizeOfImage(icon->image, &w, &h);
- }
- else {
- ZnSizeOfImage(icon->mask, &w, &h);
- }
- Origin2Anchor(&icon->pos_dev, w, h, anchor, p);
+ if (icon->image == ZnUnspecifiedImage) {
+ p->x = p->y = 0.0;
}
else {
- p->x = p->y = 0.0;
+ ZnSizeOfImage(icon->image, &w, &h);
+ Origin2Anchor(&icon->pos_dev, w, h, anchor, p);
}
}
@@ -640,9 +609,6 @@ GetClipVertices(Item item,
if (icon->image != ZnUnspecifiedImage) {
ZnSizeOfImage(icon->image, &w, &h);
}
- else if (icon->mask != ZnUnspecifiedImage) {
- ZnSizeOfImage(icon->mask, &w, &h);
- }
points = (ZnPoint *) ZnListArray(item->wi->work_pts);
TRI_STRIP1(tristrip, points, 2);
points[0] = icon->pos_dev;