aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
authorlecoanet2000-11-13 10:12:58 +0000
committerlecoanet2000-11-13 10:12:58 +0000
commit96679897294bf893e91a81b0005ef05c82c03258 (patch)
tree5d466b056eda8bc959791b175c05c4e099313fe7 /generic
parentd499af80ce3f5936de9ad60c634f4045914b4992 (diff)
downloadtkzinc-96679897294bf893e91a81b0005ef05c82c03258.zip
tkzinc-96679897294bf893e91a81b0005ef05c82c03258.tar.gz
tkzinc-96679897294bf893e91a81b0005ef05c82c03258.tar.bz2
tkzinc-96679897294bf893e91a81b0005ef05c82c03258.tar.xz
Ajout de la m�thode Render et des attributs -linealpha et
-fillalpha.
Diffstat (limited to 'generic')
-rw-r--r--generic/Rectangle.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/generic/Rectangle.c b/generic/Rectangle.c
index 9f3a69a..840a45b 100644
--- a/generic/Rectangle.c
+++ b/generic/Rectangle.c
@@ -69,12 +69,16 @@ typedef struct _RectangleItemStruct {
Pixmap line_pattern;
ZnColorGradient fill_color;
ZnGradientGeom grad_geom;
+ int line_alpha;
+ int fill_alpha;
char *tile_name;
/* Private data */
ZnPoint dev[4];
ZnImage tile;
ZnColorGradient gradient;
+ ArtSVP *outline_svp;
+ ArtSVP *fill_svp;
} RectangleItemStruct, *RectangleItem;
@@ -85,6 +89,8 @@ static ZnAttrConfig rect_attrs[] = {
{ ZN_CONFIG_BOOL, "-composescale", NULL,
Tk_Offset(RectangleItemStruct, header.flags), COMPOSE_SCALE_BIT,
ZN_COORDS_FLAG, False },
+ { ZN_CONFIG_UINT, "-fillalpha", NULL,
+ Tk_Offset(RectangleItemStruct, fill_alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_GRADIENT_COLOR, "-fillcolor", NULL,
Tk_Offset(RectangleItemStruct, fill_color), 0,
ZN_DRAW_FLAG|ZN_BORDER_FLAG, False },
@@ -94,6 +100,8 @@ static ZnAttrConfig rect_attrs[] = {
Tk_Offset(RectangleItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_GRADIENT_GEOM, "-gradient", NULL,
Tk_Offset(RectangleItemStruct, grad_geom), 0, ZN_DRAW_FLAG, False },
+ { ZN_CONFIG_UINT, "-linealpha", NULL,
+ Tk_Offset(RectangleItemStruct, line_alpha), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_COLOR, "-linecolor", NULL,
Tk_Offset(RectangleItemStruct, line_color), 0,
ZN_DRAW_FLAG, False },
@@ -198,9 +206,12 @@ Init(Item item,
rect->tile = ZnUnspecifiedImage;
rect->fill_pattern = ZnUnspecifiedPattern;
rect->line_color = ZnGetColorByValue(wi->win, wi->fore_color);
+ rect->line_alpha = 255;
rect->fill_color = ZnGetColorGradient(wi->interp, wi->win,
ZnNameOfColor(wi->fore_color));
+ rect->fill_alpha = 255;
rect->grad_geom = NULL;
+ rect->outline_svp = rect->fill_svp = NULL;
return ZN_OK;
}
@@ -243,6 +254,10 @@ Clone(Item item)
if (rect->grad_geom) {
rect->grad_geom = GradientGeomDuplicate(rect->grad_geom);
}
+ if (rect->outline_svp) {
+ }
+ if (rect->fill_svp) {
+ }
}
@@ -280,6 +295,12 @@ Destroy(Item item)
if (rect->grad_geom) {
GradientGeomDelete(rect->grad_geom);
}
+ if (rect->outline_svp) {
+ art_svp_free(rect->outline_svp);
+ }
+ if (rect->fill_svp) {
+ art_svp_free(rect->fill_svp);
+ }
}
@@ -402,6 +423,50 @@ ComputeCoordinates(Item item,
item->item_bounding_box.corner.x += rect->line_width;
item->item_bounding_box.corner.y += rect->line_width;
}
+ item->item_bounding_box.orig.x -= 1;
+ item->item_bounding_box.orig.y -= 1;
+ item->item_bounding_box.corner.x += 1;
+ item->item_bounding_box.corner.y += 1;
+
+ if (wi->local_render) {
+ ArtVpath vpath[6];
+
+ if (ISSET(rect->flags, FILLED_BIT) || rect->line_width) {
+ vpath[0].code = ART_MOVETO;
+ vpath[0].x = rect->dev[0].x;
+ vpath[0].y = rect->dev[0].y;
+ vpath[1].code = ART_LINETO;
+ vpath[1].x = rect->dev[3].x;
+ vpath[1].y = rect->dev[3].y;
+ vpath[2].code = ART_LINETO;
+ vpath[2].x = rect->dev[2].x;
+ vpath[2].y = rect->dev[2].y;
+ vpath[3].code = ART_LINETO;
+ vpath[3].x = rect->dev[1].x;
+ vpath[3].y = rect->dev[1].y;
+ vpath[4].code = ART_LINETO;
+ vpath[4].x = rect->dev[0].x;
+ vpath[4].y = rect->dev[0].y;
+ vpath[5].code = ART_END;
+ }
+ if (rect->fill_svp) {
+ art_svp_free(rect->fill_svp);
+ rect->fill_svp = NULL;
+ }
+ if (ISSET(rect->flags, FILLED_BIT)) {
+ rect->fill_svp = art_svp_from_vpath(vpath);
+ }
+ if (rect->outline_svp) {
+ art_svp_free(rect->outline_svp);
+ rect->outline_svp = NULL;
+ }
+ if (rect->line_width) {
+ rect->outline_svp = art_svp_vpath_stroke(vpath,
+ ART_PATH_STROKE_JOIN_MITER,
+ ART_PATH_STROKE_CAP_SQUARE,
+ rect->line_width, 2, 1);
+ }
+ }
}
@@ -599,6 +664,38 @@ Draw(Item item)
/*
**********************************************************************************
*
+ * Render --
+ *
+ **********************************************************************************
+ */
+static void
+Render(Item item)
+{
+ WidgetInfo *wi = item->wi;
+ RectangleItem rect = (RectangleItem) item;
+ XColor *color = ZnColorGradientMidColor(wi->win, rect->fill_color);
+ ArtPixBuf *pixbuf = NULL;
+
+ if (rect->fill_svp != NULL) {
+ if (strlen(rect->tile_name) != 0) {
+ pixbuf = GetImagePixbuf(wi->win, rect->tile_name, rect->tile);
+ }
+ ITEM_P.RenderSVP(wi, rect->fill_svp, color->red, color->green,
+ color->blue, rect->fill_alpha & 0xff,
+ item->item_bounding_box.orig.x,
+ item->item_bounding_box.orig.y, pixbuf);
+ }
+ if (rect->outline_svp != NULL) {
+ ITEM_P.RenderSVP(wi, rect->outline_svp, rect->line_color->red,
+ rect->line_color->green, rect->line_color->blue,
+ rect->line_alpha & 0xff, 0, 0, NULL);
+ }
+}
+
+
+/*
+ **********************************************************************************
+ *
* IsSensitive --
*
**********************************************************************************
@@ -831,6 +928,7 @@ static ItemClassStruct RECTANGLE_ITEM_CLASS = {
ComputeCoordinates,
ToArea,
Draw,
+ Render,
IsSensitive,
Pick,
NULL, /* PickVertex */