diff options
Diffstat (limited to 'generic/Rectangle.c')
-rw-r--r-- | generic/Rectangle.c | 244 |
1 files changed, 122 insertions, 122 deletions
diff --git a/generic/Rectangle.c b/generic/Rectangle.c index f573f3f..f9a53f3 100644 --- a/generic/Rectangle.c +++ b/generic/Rectangle.c @@ -59,65 +59,65 @@ typedef struct _RectangleItemStruct { ItemStruct header; /* Public data */ - RadarPoint coords[2]; + ZnPoint coords[2]; unsigned char flags; ReliefStyle relief; LineStyle line_style; int line_width; - RadarColor line_color; + ZnColor line_color; Pixmap fill_pattern; Pixmap line_pattern; - RadarColor fill_color; + ZnColor fill_color; char *tile_name; /* Private data */ - RadarPoint dev[4]; - RadarImage tile; - RadarColorGradient gradient; + ZnPoint dev[4]; + ZnImage tile; + ZnColorGradient gradient; } RectangleItemStruct, *RectangleItem; -static RadarAttrConfig rect_attrs[] = { - { RADAR_CONFIG_BOOL, "-composerotation", NULL, +static ZnAttrConfig rect_attrs[] = { + { ZN_CONFIG_BOOL, "-composerotation", NULL, Tk_Offset(RectangleItemStruct, header.flags), COMPOSE_ROTATION_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_BOOL, "-composescale", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_BOOL, "-composescale", NULL, Tk_Offset(RectangleItemStruct, header.flags), COMPOSE_SCALE_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_COLOR, "-fillcolor", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_COLOR, "-fillcolor", NULL, Tk_Offset(RectangleItemStruct, fill_color), 0, - RADAR_DRAW_FLAG|RADAR_BORDER_FLAG, False }, - { RADAR_CONFIG_BOOL, "-filled", NULL, - Tk_Offset(RectangleItemStruct, flags), FILLED_BIT, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_PATTERN, "-fillpattern", NULL, - Tk_Offset(RectangleItemStruct, fill_pattern), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_COLOR, "-linecolor", NULL, + ZN_DRAW_FLAG|ZN_BORDER_FLAG, False }, + { ZN_CONFIG_BOOL, "-filled", NULL, + Tk_Offset(RectangleItemStruct, flags), FILLED_BIT, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_PATTERN, "-fillpattern", NULL, + Tk_Offset(RectangleItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_COLOR, "-linecolor", NULL, Tk_Offset(RectangleItemStruct, line_color), 0, - RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_PATTERN, "-linepattern", NULL, - Tk_Offset(RectangleItemStruct, line_pattern), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_LINE_STYLE, "-linestyle", NULL, - Tk_Offset(RectangleItemStruct, line_style), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_DIM, "-linewidth", NULL, - Tk_Offset(RectangleItemStruct, line_width), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_PRI, "-priority", NULL, + ZN_DRAW_FLAG, False }, + { ZN_CONFIG_PATTERN, "-linepattern", NULL, + Tk_Offset(RectangleItemStruct, line_pattern), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_LINE_STYLE, "-linestyle", NULL, + Tk_Offset(RectangleItemStruct, line_style), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_DIM, "-linewidth", NULL, + Tk_Offset(RectangleItemStruct, line_width), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_PRI, "-priority", NULL, Tk_Offset(RectangleItemStruct, header.priority), 0, - RADAR_DRAW_FLAG|RADAR_REPICK_FLAG, False }, - { RADAR_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(RectangleItemStruct, relief), 0, - RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_BOOL, "-sensitive", NULL, + ZN_DRAW_FLAG|ZN_REPICK_FLAG, False }, + { ZN_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(RectangleItemStruct, relief), 0, + ZN_DRAW_FLAG, False }, + { ZN_CONFIG_BOOL, "-sensitive", NULL, Tk_Offset(RectangleItemStruct, header.flags), SENSITIVE_BIT, - RADAR_REPICK_FLAG, False }, - { RADAR_CONFIG_TAGS, "-tags", NULL, + ZN_REPICK_FLAG, False }, + { ZN_CONFIG_TAGS, "-tags", NULL, Tk_Offset(RectangleItemStruct, header.tags), 0, 0, False }, - { RADAR_CONFIG_IMAGE, "-tile", NULL, + { ZN_CONFIG_IMAGE, "-tile", NULL, Tk_Offset(RectangleItemStruct, tile_name), 0, - RADAR_DRAW_FLAG|RADAR_TILE_FLAG, False }, - { RADAR_CONFIG_BOOL, "-visible", NULL, + ZN_DRAW_FLAG|ZN_TILE_FLAG, False }, + { ZN_CONFIG_BOOL, "-visible", NULL, Tk_Offset(RectangleItemStruct, header.flags), VISIBLE_BIT, - RADAR_DRAW_FLAG|RADAR_REPICK_FLAG|RADAR_VIS_FLAG, False }, + ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False }, - { RADAR_CONFIG_END, NULL, NULL, 0, 0, 0 } + { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 } }; @@ -140,7 +140,7 @@ RectTileChange(ClientData client_data, RectangleItem rect = (RectangleItem) client_data; InvalidateImage(rect->tile); - ITEM.Invalidate((Item) rect, RADAR_COORDS_FLAG); + ITEM.Invalidate((Item) rect, ZN_COORDS_FLAG); } @@ -175,10 +175,10 @@ Init(Item item, if (*argc < 1) { Tcl_AppendResult(wi->interp, " rectangle coords expected", NULL); - return RADAR_ERROR; + return ZN_ERROR; } result = Lang_SplitList(wi->interp, (*args)[0], &num_elems, &elems, &freeProc); - if ((result == RADAR_ERROR) || (num_elems != 4)) { + if ((result == ZN_ERROR) || (num_elems != 4)) { rect_error: #ifdef PTK if (elems != NULL && freeProc) { @@ -186,22 +186,22 @@ Init(Item item, } #endif Tcl_AppendResult(wi->interp, " malformed rectangle coords", NULL); - return RADAR_ERROR; + return ZN_ERROR; } - if (Tcl_GetDouble(wi->interp, elems[0], &rect->coords[0].x) == RADAR_ERROR) { + if (Tcl_GetDouble(wi->interp, elems[0], &rect->coords[0].x) == ZN_ERROR) { rect_error2: #ifndef PTK Tcl_Free((char *) elems); #endif goto rect_error; }; - if (Tcl_GetDouble(wi->interp, elems[1], &rect->coords[0].y) == RADAR_ERROR) { + if (Tcl_GetDouble(wi->interp, elems[1], &rect->coords[0].y) == ZN_ERROR) { goto rect_error2; }; - if (Tcl_GetDouble(wi->interp, elems[2], &rect->coords[1].x) == RADAR_ERROR) { + if (Tcl_GetDouble(wi->interp, elems[2], &rect->coords[1].x) == ZN_ERROR) { goto rect_error2; }; - if (Tcl_GetDouble(wi->interp, elems[3], &rect->coords[1].y) == RADAR_ERROR) { + if (Tcl_GetDouble(wi->interp, elems[3], &rect->coords[1].y) == ZN_ERROR) { goto rect_error2; }; (*args)++; @@ -218,14 +218,14 @@ Init(Item item, rect->relief = RELIEF_FLAT; rect->line_style = LINE_SIMPLE; rect->line_width = 1; - rect->line_pattern = RadarUnspecifiedPattern; + rect->line_pattern = ZnUnspecifiedPattern; rect->tile_name = ""; - rect->tile = RadarUnspecifiedImage; - rect->fill_pattern = RadarUnspecifiedPattern; - rect->line_color = RadarGetColorByValue(wi->win, wi->fore_color); - rect->fill_color = RadarGetColorByValue(wi->win, wi->fore_color); + rect->tile = ZnUnspecifiedImage; + rect->fill_pattern = ZnUnspecifiedPattern; + rect->line_color = ZnGetColorByValue(wi->win, wi->fore_color); + rect->fill_color = ZnGetColorByValue(wi->win, wi->fore_color); - return RADAR_OK; + return ZN_OK; } @@ -244,25 +244,25 @@ Clone(Item item) char *text; if (rect->gradient) { - rect->gradient = RadarGetColorGradientByValue(rect->gradient); + rect->gradient = ZnGetColorGradientByValue(rect->gradient); } if (strlen(rect->tile_name) != 0) { - text = RadarMalloc((strlen(rect->tile_name) + 1) * sizeof(char)); + text = ZnMalloc((strlen(rect->tile_name) + 1) * sizeof(char)); strcpy(text, rect->tile_name); rect->tile_name = text; rect->tile = Tk_GetImage(wi->interp, wi->win, rect->tile_name, RectTileChange, (ClientData) rect); } - if (rect->line_pattern != RadarUnspecifiedPattern) { + if (rect->line_pattern != ZnUnspecifiedPattern) { rect->line_pattern = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, rect->line_pattern)); } - if (rect->fill_pattern != RadarUnspecifiedPattern) { + if (rect->fill_pattern != ZnUnspecifiedPattern) { rect->fill_pattern = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, rect->fill_pattern)); } - rect->line_color = RadarGetColorByValue(wi->win, rect->line_color); - rect->fill_color = RadarGetColorByValue(wi->win, rect->fill_color); + rect->line_color = ZnGetColorByValue(wi->win, rect->line_color); + rect->fill_color = ZnGetColorByValue(wi->win, rect->fill_color); } @@ -280,23 +280,23 @@ Destroy(Item item) RectangleItem rect = (RectangleItem) item; if (strlen(rect->tile_name) != 0) { - RadarFree(rect->tile_name); + ZnFree(rect->tile_name); } - if (rect->tile != RadarUnspecifiedImage) { + if (rect->tile != ZnUnspecifiedImage) { Tk_FreeImage(rect->tile); - rect->tile = RadarUnspecifiedImage; + rect->tile = ZnUnspecifiedImage; } if (rect->gradient) { - RadarFreeColorGradient(rect->gradient); + ZnFreeColorGradient(rect->gradient); } - if (rect->line_pattern != RadarUnspecifiedPattern) { + if (rect->line_pattern != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, rect->line_pattern); } - if (rect->fill_pattern != RadarUnspecifiedPattern) { + if (rect->fill_pattern != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, rect->fill_pattern); } - RadarFreeColor(rect->fill_color); - RadarFreeColor(rect->line_color); + ZnFreeColor(rect->fill_color); + ZnFreeColor(rect->line_color); } @@ -310,26 +310,26 @@ Destroy(Item item) static int Configure(Item item, int argc, - RadarAttrList argv, + ZnAttrList argv, int *flags) { WidgetInfo *wi = item->wi; RectangleItem rect = (RectangleItem) item; - if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == RADAR_ERROR) { - return RADAR_ERROR; + if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == ZN_ERROR) { + return ZN_ERROR; } if (rect->gradient && - (ISSET(*flags, RADAR_BORDER_FLAG) || (rect->relief == RELIEF_FLAT))) { - RadarFreeColorGradient(rect->gradient); + (ISSET(*flags, ZN_BORDER_FLAG) || (rect->relief == RELIEF_FLAT))) { + ZnFreeColorGradient(rect->gradient); rect->gradient = NULL; } if ((rect->relief != RELIEF_FLAT) && !rect->gradient) { - rect->gradient = RadarGetReliefGradient(wi->interp, wi->win, - RadarNameOfColor(rect->fill_color)); + rect->gradient = ZnGetReliefGradient(wi->interp, wi->win, + ZnNameOfColor(rect->fill_color)); } - if (ISSET(*flags, RADAR_TILE_FLAG)) { + if (ISSET(*flags, ZN_TILE_FLAG)) { Tk_Image tile; if (strcmp(rect->tile_name, "") != 0) { @@ -340,19 +340,19 @@ Configure(Item item, * The name will not be in sync with the image in * this case. */ - return RADAR_ERROR; + return ZN_ERROR; } } else { - tile = RadarUnspecifiedImage; + tile = ZnUnspecifiedImage; } - if (rect->tile != RadarUnspecifiedImage) { + if (rect->tile != ZnUnspecifiedImage) { Tk_FreeImage(rect->tile); } rect->tile = tile; } - return RADAR_OK; + return ZN_OK; } @@ -366,13 +366,13 @@ Configure(Item item, static int Query(Item item, int argc, - RadarAttrList argv) + ZnAttrList argv) { - if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == RADAR_ERROR) { - return RADAR_ERROR; + if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == ZN_ERROR) { + return ZN_ERROR; } - return RADAR_OK; + return ZN_OK; } @@ -385,11 +385,11 @@ Query(Item item, */ static void ComputeCoordinates(Item item, - RadarBool force) + ZnBool force) { WidgetInfo *wi = item->wi; RectangleItem rect = (RectangleItem) item; - RadarPoint p[4]; + ZnPoint p[4]; ResetBBox(&item->item_bounding_box); if (!rect->line_width && ISCLEAR(rect->flags, FILLED_BIT)) { @@ -402,7 +402,7 @@ ComputeCoordinates(Item item, p[1].y = p[0].y; p[3].x = p[0].x; p[3].y = p[2].y; - RadarTransformPoints(wi->current_transfo, p, rect->dev, 4); + ZnTransformPoints(wi->current_transfo, p, rect->dev, 4); /* * Add all points to the bounding box. Then expand by the line @@ -428,11 +428,11 @@ ComputeCoordinates(Item item, ********************************************************************************** */ static int -ToArea(Item item, - RadarBBox *area, - Tk_Uid tag_uid, - int enclosed, - RadarBool report) +ToArea(Item item, + ZnBBox *area, + Tk_Uid tag_uid, + int enclosed, + ZnBool report) { RectangleItem rect = (RectangleItem) item; int result; @@ -444,7 +444,7 @@ ToArea(Item item, } else if (rect->line_width > 0) { int i; - RadarPoint pts[5]; + ZnPoint pts[5]; for (i = 0; i < 4; i++) { pts[i] = rect->dev[i]; @@ -472,8 +472,8 @@ Draw(Item item) RectangleItem rect = (RectangleItem) item; XGCValues values; int i, gc_mask; - RadarBool aligned; - RadarDim delta; + ZnBool aligned; + ZnDim delta; XRectangle r; XPoint xp[5]; @@ -514,8 +514,8 @@ Draw(Item item) * Fill if requested. */ if (ISSET(rect->flags, FILLED_BIT)) { - values.foreground = RadarPixel(rect->fill_color); - if (rect->tile != RadarUnspecifiedImage) { /* Fill tiled */ + values.foreground = ZnPixel(rect->fill_color); + if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */ Pixmap pmap = GetImagePixmap(wi->win, rect->tile); values.fill_style = FillTiled; values.tile = pmap; @@ -524,7 +524,7 @@ Draw(Item item) XChangeGC(wi->dpy, wi->gc, GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile, &values); } - else if (rect->fill_pattern != RadarUnspecifiedPattern) { /* Fill stippled */ + else if (rect->fill_pattern != ZnUnspecifiedPattern) { /* Fill stippled */ values.fill_style = FillStippled; values.stipple = rect->fill_pattern; values.ts_x_origin = (int) item->item_bounding_box.orig.x; @@ -554,7 +554,7 @@ Draw(Item item) &r, rect->line_width); } else { - RadarPoint p[5]; + ZnPoint p[5]; for (i = 0; i < 4; i++) { p[4-i].x = rect->dev[i].x; p[4-i].y = rect->dev[i].y; @@ -567,14 +567,14 @@ Draw(Item item) else { SetLineStyle(wi->dpy, wi->gc, rect->line_style); gc_mask = GCFillStyle|GCLineWidth|GCForeground|GCJoinStyle; - values.foreground = RadarPixel(rect->line_color); + values.foreground = ZnPixel(rect->line_color); values.line_width = (rect->line_width == 1) ? 0 : rect->line_width; values.join_style = JoinMiter; if (!aligned) { gc_mask |= GCCapStyle; values.cap_style = CapProjecting; } - if (rect->line_pattern == RadarUnspecifiedPattern) { + if (rect->line_pattern == ZnUnspecifiedPattern) { values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, gc_mask, &values); } @@ -603,12 +603,12 @@ Draw(Item item) * ********************************************************************************** */ -static RadarBool +static ZnBool IsSensitive(Item item, int item_part) { return (ISSET(item->flags, SENSITIVE_BIT) && - item->parent->class->IsSensitive(item->parent, RADAR_NO_PART)); + item->parent->class->IsSensitive(item->parent, ZN_NO_PART)); } @@ -621,7 +621,7 @@ IsSensitive(Item item, */ static double Pick(Item item, - RadarPoint *p, + ZnPoint *p, Item start_item, int aperture, Item *a_item, @@ -642,7 +642,7 @@ Pick(Item item, if (rect->line_width > 1) { double dist; int i; - RadarPoint pts[5]; + ZnPoint pts[5]; for (i = 0; i < 4; i++) { pts[i] = rect->dev[i]; @@ -682,14 +682,14 @@ PostScript(Item item, * ********************************************************************************** */ -static RadarBool -GetClipVertices(Item item, - RadarPoint **points, - int *num_points) +static ZnBool +GetClipVertices(Item item, + ZnPoint **points, + int *num_points) { RectangleItem rect = (RectangleItem) item; double delta; - RadarBool aligned; + ZnBool aligned; delta = rect->dev[0].y - rect->dev[1].y; delta = ABS(delta); @@ -699,8 +699,8 @@ GetClipVertices(Item item, aligned |= delta < PRECISION_LIMIT; if (aligned) { - RadarListAssertSize(item->wi->work_pts, 2); - *points = (RadarPoint *) RadarListArray(item->wi->work_pts); + ZnListAssertSize(item->wi->work_pts, 2); + *points = (ZnPoint *) ZnListArray(item->wi->work_pts); *num_points = 2; if (rect->dev[0].x < rect->dev[2].x) { @@ -738,34 +738,34 @@ GetClipVertices(Item item, ********************************************************************************** */ static int -Coords(Item item, - int index, - int cmd, - RadarPoint **pts, - int *num_pts) +Coords(Item item, + int index, + int cmd, + ZnPoint **pts, + int *num_pts) { RectangleItem rect = (RectangleItem) item; if ((cmd == COORDS_ADD) || (cmd == COORDS_ADD_LAST) || (cmd == COORDS_REMOVE)) { Tcl_AppendResult(item->wi->interp, " rectangles can't add or remove vertices", NULL); - return RADAR_ERROR; + return ZN_ERROR; } else if (cmd == COORDS_REPLACE_ALL) { if (*num_pts != 2) { Tcl_AppendResult(item->wi->interp, " coords command need 2 points on rectangles", NULL); - return RADAR_ERROR; + return ZN_ERROR; } rect->coords[0] = (*pts)[0]; rect->coords[1] = (*pts)[1]; - ITEM.Invalidate(item, RADAR_COORDS_FLAG); + ITEM.Invalidate(item, ZN_COORDS_FLAG); } else if (cmd == COORDS_REPLACE) { if (*num_pts < 1) { Tcl_AppendResult(item->wi->interp, " coords command need at least 1 point", NULL); - return RADAR_ERROR; + return ZN_ERROR; } if (index < 0) { index += 2; @@ -774,10 +774,10 @@ Coords(Item item, range_err: Tcl_AppendResult(item->wi->interp, " incorrect coord index, should be between -2 and 1", NULL); - return RADAR_ERROR; + return ZN_ERROR; } rect->coords[index] = (*pts)[0]; - ITEM.Invalidate(item, RADAR_COORDS_FLAG); + ITEM.Invalidate(item, ZN_COORDS_FLAG); } else if (cmd == COORDS_READ_ALL) { *num_pts = 2; @@ -794,7 +794,7 @@ Coords(Item item, *pts = &rect->coords[index]; } - return RADAR_OK; + return ZN_OK; } @@ -829,4 +829,4 @@ static ItemClassStruct RECTANGLE_ITEM_CLASS = { PostScript }; -RadarItemClassId RadarRectangle = (RadarItemClassId) &RECTANGLE_ITEM_CLASS; +ZnItemClassId ZnRectangle = (ZnItemClassId) &RECTANGLE_ITEM_CLASS; |