From 96679897294bf893e91a81b0005ef05c82c03258 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Mon, 13 Nov 2000 10:12:58 +0000 Subject: Ajout de la m�thode Render et des attributs -linealpha et -fillalpha. --- generic/Rectangle.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'generic/Rectangle.c') 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 */ -- cgit v1.1