From b9432a0acdcedbae106a891584a6e55bdbee55bd Mon Sep 17 00:00:00 2001 From: lecoanet Date: Thu, 11 May 2000 14:00:52 +0000 Subject: Correction de bugs li�s � l'utilisation de ZnFree au lieu de Tcl_Free pour la lib�ration de ressources TCL (listes). Adaptations suite � l'introduction des polygones multi-contours. --- generic/Item.c | 98 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 28 deletions(-) (limited to 'generic/Item.c') diff --git a/generic/Item.c b/generic/Item.c index edb90eb..1aaa2e0 100644 --- a/generic/Item.c +++ b/generic/Item.c @@ -516,7 +516,7 @@ ConfigureAttributes(char *record, "\" in pattern list", NULL); ZnListFree(new_pat_list); #ifndef PTK - ZnFree(elems); + Tcl_Free((char *) elems); #else if (freeProc) { (*freeProc)(num_pats, elems); @@ -530,7 +530,13 @@ ConfigureAttributes(char *record, } } } - ZnFree(elems); +#ifndef PTK + Tcl_Free((char *) elems); +#else + if (freeProc) { + (*freeProc)(num_pats, elems); + } +#endif } if (*((ZnList *) valp)) { num_pats = ZnListSize(*((ZnList *) valp)); @@ -584,7 +590,7 @@ ConfigureAttributes(char *record, *flags |= desc->flags; } #ifndef PTK - ZnFree(elems); + Tcl_Free((char *)elems); #else if (freeProc) { (*freeProc)(num_tags, elems); @@ -682,13 +688,13 @@ ConfigureAttributes(char *record, } else { #ifndef PTK - ZnFree(largv); + Tcl_Free((char *) largv); #endif goto border_error; } } #ifndef PTK - ZnFree(largv); + Tcl_Free((char *) largv); #else if (largv != NULL && freeProc) { (*freeProc)(largc, largv); @@ -874,12 +880,12 @@ ConfigureAttributes(char *record, if ((Tcl_GetDouble(wi->interp, largv[0], &point.x) == ZN_ERROR) || (Tcl_GetDouble(wi->interp, largv[1], &point.y) == ZN_ERROR)) { #ifndef PTK - ZnFree(largv); + Tcl_Free((char *)largv); #endif goto point_error; } #ifndef PTK - ZnFree(largv); + Tcl_Free((char *)largv); #else if (largv != NULL && freeProc) { (*freeProc)(largc, largv); @@ -918,12 +924,12 @@ ConfigureAttributes(char *record, (Tcl_GetDouble(wi->interp, largv[2], &rect.w) == ZN_ERROR) || (Tcl_GetDouble(wi->interp, largv[3], &rect.h) == ZN_ERROR)) { #ifndef PTK - ZnFree(largv); + Tcl_Free((char *)largv); #endif goto rect_error; } #ifndef PTK - ZnFree(largv); + Tcl_Free((char *)largv); #else if (largv != NULL && freeProc) { (*freeProc)(largc, largv); @@ -1756,6 +1762,7 @@ GlobalModuleInit() AddItemClass(ZnRectangle); AddItemClass(ZnArc); AddItemClass(ZnCurve); + AddItemClass(ZnBezier); AddItemClass(ZnGroup); AddItemClass(ZnIcon); AddItemClass(ZnText); @@ -3284,20 +3291,37 @@ CurrentClip(WidgetInfo *wi, return False; } +/* + * If simple is True poly is a pointer to an + * array of two points. In the other case it + * is a regular pointer to a multi contour poly. + */ static void PushClip(WidgetInfo *wi, - ZnPoint *pts, - int num_pts, + ZnPoly *poly, ZnBool simple, ZnBool set_gc) { - int i, num_c; + int i, j, num_c; + int num_pts, max_num_pts; + ZnPoint *p; ClipState *previous_clip=NULL; - Region reg; + Region reg, reg_op, reg_to; XRectangle rect; XPoint *xpts; - if (num_pts == 0) { + if (poly->num_contours == 0) { + return; + } + max_num_pts = poly->contours[0].num_points; + for (j = 0; j < poly->num_contours; j++) { + num_pts = poly->contours[j].num_points; + if (num_pts > max_num_pts) { + num_pts = max_num_pts; + } + } + if ((simple && (max_num_pts < 2)) || + (!simple && (max_num_pts < 3))) { return; } @@ -3309,27 +3333,42 @@ PushClip(WidgetInfo *wi, ZnListAssertSize(wi->clip_stack, num_c+1); wi->current_clip = (ClipState *) ZnListAt(wi->clip_stack, ZnListTail); wi->current_clip->simple = simple; - + /* * Compute the local region. */ if (simple) { - rect.x = pts[0].x; - rect.y = pts[0].y; - rect.width = pts[1].x - pts[0].x; - rect.height = pts[1].y - pts[0].y; + rect.x = poly->contours[0].points[0].x; + rect.y = poly->contours[0].points[0].y; + rect.width = poly->contours[0].points[1].x - poly->contours[0].points[0].x; + rect.height = poly->contours[0].points[1].y - poly->contours[0].points[0].y; reg = XCreateRegion(); XUnionRectWithRegion(&rect, reg, reg); /*printf("Adding a simple clip: %d, %d, %d, %d\n", rect.x, rect.y, rect.width, rect.height);*/ } else { - xpts = (XPoint *) ZnMalloc(num_pts * sizeof(XPoint)); - for (i = 0; i < num_pts; i++) { - xpts[i].x = pts[i].x; - xpts[i].y = pts[i].y; + xpts = (XPoint *) ZnMalloc(max_num_pts * sizeof(XPoint)); + reg = XCreateRegion(); + for (j = 0; j < poly->num_contours; j++) { + num_pts = poly->contours[j].num_points; + p = poly->contours[j].points; + for (i = 0; i < num_pts; i++, p++) { + xpts[i].x = p->x; + xpts[i].y = p->y; + } + reg_op = XPolygonRegion(xpts, num_pts, EvenOddRule); + reg_to = XCreateRegion(); + if (poly->holes[j]) { + XSubtractRegion(reg, reg_op, reg_to); + } + else { + XUnionRegion(reg, reg_op, reg_to); + } + XDestroyRegion(reg); + XDestroyRegion(reg_op); + reg = reg_to; } - reg = XPolygonRegion(xpts, num_pts, EvenOddRule); ZnFree(xpts); } /* @@ -4092,6 +4131,7 @@ DrawFields(FieldSet field_set) ZnBBox label_clip_box, clip_bbox, bbox, *global_clip_box; ZnBBox text_bbox, clip_text_bbox; ZnPoint pts[2]; + ZnPoly poly; XRectangle r; ZnPoint text_pos; ZnBBox pm_bbox, clip_pm_bbox; @@ -4154,7 +4194,8 @@ DrawFields(FieldSet field_set) /* we must clip. */ pts[0] = clip_bbox.orig; pts[1] = clip_bbox.corner; - PushClip(wi, pts, 2, True, True); + POLY_CONTOUR1(&poly, pts, 2); + PushClip(wi, &poly, True, True); restore = True; } @@ -4492,7 +4533,8 @@ Repair(WidgetInfo *wi) XGCValues values; XRectangle r; ZnPoint pts[2]; - + ZnPoly poly; + /* To be done only if we are realized and there is something to update. */ if (wi->realized && !IsEmptyBBox(&wi->damaged_area)) { @@ -4510,8 +4552,8 @@ Repair(WidgetInfo *wi) r.height = wi->damaged_area.corner.y - wi->damaged_area.orig.y; pts[0] = wi->damaged_area.orig; pts[1] = wi->damaged_area.corner; - - PushClip(wi, pts, 2, True, True); + POLY_CONTOUR1(&poly, pts, 2); + PushClip(wi, &poly, True, True); #ifdef PERFOS XStartChrono(draw_time, wi->dpy, wi->draw_buffer); -- cgit v1.1