diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Tabular.c | 126 | ||||
-rw-r--r-- | generic/Track.c | 171 |
2 files changed, 233 insertions, 64 deletions
diff --git a/generic/Tabular.c b/generic/Tabular.c index c24244c..009576f 100644 --- a/generic/Tabular.c +++ b/generic/Tabular.c @@ -136,7 +136,7 @@ Init(Item item, &field_set->num_fields) != ZN_ERROR)) { *args += 1; *argc -= 1; - ITEM_P.InitFields(field_set); + FIELD.InitFields(field_set); } else { Tcl_AppendResult(wi->interp, " number of fields expected", NULL); @@ -159,7 +159,7 @@ Init(Item item, static void Clone(Item item) { - ITEM_P.CloneFields(&((TabularItem) item)->field_set); + FIELD.CloneFields(&((TabularItem) item)->field_set); } @@ -173,7 +173,7 @@ Clone(Item item) static void Destroy(Item item) { - ITEM_P.FreeFields(&((TabularItem) item)->field_set); + FIELD.FreeFields(&((TabularItem) item)->field_set); } @@ -193,7 +193,8 @@ Configure(Item item, Item old_connected; old_connected = item->connected_item; - if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == ZN_ERROR) { + if (ZnConfigureAttributes(item->wi, item, tabular_attrs, + argc, argv, flags) == ZN_ERROR) { return ZN_ERROR; } if (ISSET(*flags, ZN_ITEM_FLAG)) { @@ -227,7 +228,7 @@ Query(Item item, int argc, Tcl_Obj *CONST argv[]) { - if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == ZN_ERROR) { + if (ZnQueryAttribute(item->wi, item, tabular_attrs, argv[0]) == ZN_ERROR) { return ZN_ERROR; } @@ -253,7 +254,7 @@ ComputeCoordinates(Item item, ResetBBox(&item->item_bounding_box); if (field_set->label_format) { - ITEM_P.GetLabelBBox(field_set, &width, &height); + FIELD.GetLabelBBox(field_set, &width, &height); /* * The connected item support anchors, this is checked by @@ -303,7 +304,7 @@ ToArea(Item item, int enclosed, ZnBool report) { - return ITEM_P.FieldsToArea(&((TabularItem) item)->field_set, area); + return FIELD.FieldsToArea(&((TabularItem) item)->field_set, area); } @@ -317,7 +318,7 @@ ToArea(Item item, static void Draw(Item item) { - ITEM_P.DrawFields(&((TabularItem) item)->field_set); + FIELD.DrawFields(&((TabularItem) item)->field_set, item); } @@ -331,7 +332,7 @@ Draw(Item item) static void Render(Item item) { - ITEM_P.RenderFields(&((TabularItem) item)->field_set); + FIELD.RenderFields(&((TabularItem) item)->field_set, item); } @@ -354,7 +355,7 @@ IsSensitive(Item item, return ISSET(item->flags, SENSITIVE_BIT); } else { - return ITEM_P.IsFieldSensitive(&((TabularItem) item)->field_set, item_part); + return FIELD.IsFieldSensitive(&((TabularItem) item)->field_set, item_part); } } @@ -378,7 +379,7 @@ Pick(Item item, int best_part; double dist; - dist = ITEM_P.FieldsPick(&((TabularItem) item)->field_set, p, &best_part); + dist = FIELD.FieldsPick(&((TabularItem) item)->field_set, p, &best_part); /*printf("tabular %d reporting part %d, distance %lf\n", item->id, best_part, dist);*/ if (dist <= 0.0) { @@ -434,7 +435,7 @@ GetAnchor(Item item, ZnDim width, height; if (field_set->label_format) { - ITEM_P.GetLabelBBox(field_set, &width, &height); + FIELD.GetLabelBBox(field_set, &width, &height); Origin2Anchor(&field_set->label_pos, width, height, anchor, p); } else { @@ -461,7 +462,7 @@ GetClipVertices(Item item, ZnPoint *points; if (field_set->label_format) { - ITEM_P.GetLabelBBox(field_set, &width, &height); + FIELD.GetLabelBBox(field_set, &width, &height); ZnListAssertSize(item->wi->work_pts, 2); points = (ZnPoint *) ZnListArray(item->wi->work_pts); TRI_STRIP1(tristrip, points, 2); @@ -565,6 +566,95 @@ Part(Item item, /* ********************************************************************************** * + * Index -- + * Parse a text index and return its value and aa + * error status (standard Tcl result). + * + ********************************************************************************** + */ +static int +Index(Item item, + int field, + Tcl_Obj *index_spec, + int *index) +{ + return FIELD.FieldIndex(&((TabularItem) item)->field_set, field, + item, index_spec, index); +} + + +/* + ********************************************************************************** + * + * InsertChars -- + * + ********************************************************************************** + */ +static void +InsertChars(Item item, + int field, + int *index, + char *chars) +{ + FIELD.FieldInsertChars(&((TabularItem) item)->field_set, field, index, chars); +} + + +/* + ********************************************************************************** + * + * DeleteChars -- + * + ********************************************************************************** + */ +static void +DeleteChars(Item item, + int field, + int *first, + int *last) +{ + FIELD.FieldDeleteChars(&((TabularItem) item)->field_set, field, first, last); +} + + +/* + ********************************************************************************** + * + * Cursor -- + * + ********************************************************************************** + */ +static void +TabularCursor(Item item, + int field, + int index) +{ + FIELD.FieldCursor(&((TabularItem) item)->field_set, field, index); +} + + +/* + ********************************************************************************** + * + * Selection -- + * + ********************************************************************************** + */ +static int +Selection(Item item, + int field, + int offset, + char *chars, + int max_chars) +{ + return FIELD.FieldSelection(&((TabularItem) item)->field_set, field, + offset, chars, max_chars); +} + + +/* + ********************************************************************************** + * * Exported functions structs -- * ********************************************************************************** @@ -586,12 +676,12 @@ static ItemClassStruct TABULAR_ITEM_CLASS = { GetClipVertices, NULL, /* GetContours */ Coords, - NULL, /* InsertChars */ - NULL, /* DeleteChars */ - NULL, /* Cursor */ - NULL, /* Index */ + InsertChars, + DeleteChars, + TabularCursor, + Index, Part, - NULL, /* Selection */ + Selection, NULL, /* Contour */ ComputeCoordinates, ToArea, diff --git a/generic/Track.c b/generic/Track.c index f039b93..e7ebc6b 100644 --- a/generic/Track.c +++ b/generic/Track.c @@ -31,6 +31,7 @@ #include "Draw.h" #include "Geo.h" #include "Item.h" +#include "Group.h" #include "Types.h" #include "WidgetInfo.h" #include "Image.h" @@ -423,7 +424,7 @@ Init(Item item, (Tcl_GetIntFromObj(wi->interp, (*args)[0], &field_set->num_fields) != ZN_ERROR)) { *args += 1; *argc -= 1; - ITEM_P.InitFields(field_set); + FIELD.InitFields(field_set); } else { Tcl_AppendResult(wi->interp, " number of fields expected", NULL); @@ -480,7 +481,7 @@ Clone(Item item) LineEndDuplicate(track->leader_last_end); } - ITEM_P.CloneFields(&track->field_set); + FIELD.CloneFields(&track->field_set); /* * We get all shared resources, colors bitmaps. @@ -545,7 +546,7 @@ Destroy(Item item) Tk_FreeBitmap(wi->dpy, track->marker_fill_pattern); } - ITEM_P.FreeFields(&track->field_set); + FIELD.FreeFields(&track->field_set); } @@ -593,14 +594,11 @@ Configure(Item item, WidgetInfo *wi = item->wi; Item old_connected; ZnPoint old_pos; -#ifdef OM - GroupItem group = (GroupItem) item->parent; -#endif old_pos = track->pos; old_connected = item->connected_item; - if (ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags) == ZN_ERROR) { + if (ZnConfigureAttributes(wi, item, track_attrs, argc, argv, flags) == ZN_ERROR) { return ZN_ERROR; } @@ -614,15 +612,11 @@ Configure(Item item, */ if (ISSET(*flags, ZN_POLAR_FLAG)) { SET(track->flags, POLAR_BIT); -#ifdef OM - group->call_om = True; -#endif + ZnGroupSetCallOm(item->parent, True); } else if (ISSET(*flags, ZN_CARTESIAN_FLAG)) { CLEAR(track->flags, POLAR_BIT); -#ifdef OM - group->call_om = True; -#endif + ZnGroupSetCallOm(item->parent, True); } if (ISSET(*flags, ZN_ITEM_FLAG)) { @@ -641,22 +635,18 @@ Configure(Item item, } } -#ifdef OM if (ISSET(*flags, ZN_VIS_FLAG)) { /* Record the change to trigger the overlap manager latter */ if ((item->class == ZnTrack) && ISSET(item->flags, VISIBLE_BIT)) { - group->call_om = True; + ZnGroupSetCallOm(item->parent, True); } } -#endif /* If the current position has changed, shift the past pos. */ if (ISSET(*flags, ZN_MOVED_FLAG)) { if (item->class == ZnTrack) { AddToHistory(track, old_pos); -#ifdef OM - group->call_om = True; -#endif + ZnGroupSetCallOm(item->parent, True); } } @@ -676,7 +666,7 @@ Query(Item item, int argc, Tcl_Obj *CONST argv[]) { - if (ITEM_P.QueryAttribute((char *) item, -1, argv[0]) == ZN_ERROR) { + if (ZnQueryAttribute(item->wi, item, track_attrs, argv[0]) == ZN_ERROR) { return ZN_ERROR; } @@ -821,7 +811,7 @@ ComputeCoordinates(Item item, ZnDim bb_width, bb_height, dist; ZnPoint leader_end; - ITEM_P.GetLabelBBox(field_set, &bb_width, &bb_height); + FIELD.GetLabelBBox(field_set, &bb_width, &bb_height); /* * Compute the label position. */ @@ -892,7 +882,7 @@ ComputeCoordinates(Item item, } if (track->label_angle >= 270 || track->label_angle < 90) { if (track->leader_anchors && (left_y < 0)) { - ITEM_P.GetFieldBBox(field_set, left_x, &bbox); + FIELD.GetFieldBBox(field_set, left_x, &bbox); leader_end.x = bbox.orig.x; leader_end.y = bbox.corner.y; } @@ -904,7 +894,7 @@ ComputeCoordinates(Item item, } else { if (track->leader_anchors && (right_y < 0)) { - ITEM_P.GetFieldBBox(field_set, right_x, &bbox); + FIELD.GetFieldBBox(field_set, right_x, &bbox); leader_end.x = bbox.corner.x; leader_end.y = bbox.corner.y; } @@ -915,10 +905,10 @@ ComputeCoordinates(Item item, alignment = AA_RIGHT; } - ITEM.SetFieldsAutoAlign(item, alignment); + FIELD.SetFieldsAutoAlign(field_set, alignment); /* Clip the leader on the label's fields */ - ITEM_P.LeaderToLabel(field_set, &track->dev, &leader_end); + FIELD.LeaderToLabel(field_set, &track->dev, &leader_end); /* Setup leader shape points */ if (!track->leader_points) { @@ -1001,9 +991,9 @@ ToArea(Item item, /* * Try the fields. */ - ITEM_P.GetLabelBBox(&track->field_set, &lwidth, &lheight); + FIELD.GetLabelBBox(&track->field_set, &lwidth, &lheight); if ((lwidth > 0.0) && (lheight > 0.0)) { - if (ITEM_P.FieldsToArea(&track->field_set, area) != inside) { + if (FIELD.FieldsToArea(&track->field_set, area) != inside) { return 0; } } @@ -1274,7 +1264,7 @@ Draw(Item item) /* * Draw the label. */ - ITEM_P.DrawFields(&track->field_set); + FIELD.DrawFields(&track->field_set, item); } @@ -1535,7 +1525,7 @@ Render(Item item) /* * Render the label. */ - ITEM_P.RenderFields(&track->field_set); + FIELD.RenderFields(&track->field_set, item); #endif } @@ -1559,7 +1549,7 @@ IsSensitive(Item item, return ISSET(item->part_sensitive, PART_NUMBER_TO_BIT(item_part)); } else if (item_part >= 0) { - return ITEM_P.IsFieldSensitive(&((TrackItem) item)->field_set, item_part); + return FIELD.IsFieldSensitive(&((TrackItem) item)->field_set, item_part); } else if (item_part == ZN_NO_PART) { return ISSET(item->flags, SENSITIVE_BIT); @@ -1598,7 +1588,7 @@ Pick(Item item, /* * Try one of the fields. */ - dist = ITEM_P.FieldsPick(&track->field_set, p, &best_part); + dist = FIELD.FieldsPick(&track->field_set, p, &best_part); if (dist <= 0.0) { goto report0; } @@ -1775,7 +1765,7 @@ SendTrackToOm(void *ptr, zn_bbox.corner.y = wi->height; if (current_item == ZN_NO_ITEM) { - current_item = ((GroupItem) wi->om_group)->head; + current_item = ZnGroupHead(wi->om_group); } else { current_item = current_item->next; @@ -1811,7 +1801,7 @@ SendTrackToOm(void *ptr, if (track->field_set.label_format) { ZnDim bb_width, bb_height; - ITEM_P.GetLabelBBox(&track->field_set, &bb_width, &bb_height); + FIELD.GetLabelBBox(&track->field_set, &bb_width, &bb_height); *label_width = bb_width; *label_height = bb_height; } @@ -1876,7 +1866,7 @@ SetLabelAngleFromOm(void *ptr, /* No longer in use. */ #endif SET(track->flags, POLAR_BIT); ITEM.Invalidate((Item) item, ZN_COORDS_FLAG); - ((GroupItem) ((Item) item)->parent)->call_om = True; + ZnGroupSetCallOm(((Item)item)->parent, True); } } @@ -1912,7 +1902,7 @@ QueryLabelPosition(void *ptr, /* No longer in use. */ */ heading = ProjectionToAngle(track->speed_vector.x, track->speed_vector.y); PointPolarToCartesian(heading, track->label_distance, theta, &delta_x, &delta_y); - ITEM_P.GetLabelBBox(&track->field_set, &bb_width, &bb_height); + FIELD.GetLabelBBox(&track->field_set, &bb_width, &bb_height); /* * !! BUG !! This assume a label placing relative to the center anchor. * We must fix this by taking into account the label anchor. @@ -1998,7 +1988,7 @@ GetAnchor(Item item, ZnDim width, height; if (field_set->label_format) { - ITEM_P.GetLabelBBox(field_set, &width, &height); + FIELD.GetLabelBBox(field_set, &width, &height); Origin2Anchor(&field_set->label_pos, width, height, anchor, p); } else { @@ -2139,6 +2129,95 @@ Part(Item item, /* ********************************************************************************** * + * Index -- + * Parse a text index and return its value and aa + * error status (standard Tcl result). + * + ********************************************************************************** + */ +static int +Index(Item item, + int field, + Tcl_Obj *index_spec, + int *index) +{ + return FIELD.FieldIndex(&((TrackItem) item)->field_set, field, + item, index_spec, index); +} + + +/* + ********************************************************************************** + * + * InsertChars -- + * + ********************************************************************************** + */ +static void +InsertChars(Item item, + int field, + int *index, + char *chars) +{ + FIELD.FieldInsertChars(&((TrackItem) item)->field_set, field, index, chars); +} + + +/* + ********************************************************************************** + * + * DeleteChars -- + * + ********************************************************************************** + */ +static void +DeleteChars(Item item, + int field, + int *first, + int *last) +{ + FIELD.FieldDeleteChars(&((TrackItem) item)->field_set, field, first, last); +} + + +/* + ********************************************************************************** + * + * Cursor -- + * + ********************************************************************************** + */ +static void +TrackCursor(Item item, + int field, + int index) +{ + FIELD.FieldCursor(&((TrackItem) item)->field_set, field, index); +} + + +/* + ********************************************************************************** + * + * Selection -- + * + ********************************************************************************** + */ +static int +Selection(Item item, + int field, + int offset, + char *chars, + int max_chars) +{ + return FIELD.FieldSelection(&((TrackItem) item)->field_set, field, + offset, chars, max_chars); +} + + +/* + ********************************************************************************** + * * Exported functions struct -- * ********************************************************************************** @@ -2160,12 +2239,12 @@ static ItemClassStruct TRACK_ITEM_CLASS = { NULL, /* GetClipVertices */ NULL, /* GetContours */ Coords, - NULL, /* InsertChars */ - NULL, /* DeleteChars */ - NULL, /* Cursor */ - NULL, /* Index */ + InsertChars, + DeleteChars, + TrackCursor, + Index, Part, - NULL, /* Selection */ + Selection, NULL, /* Contour */ ComputeCoordinates, ToArea, @@ -2194,12 +2273,12 @@ static ItemClassStruct WAY_POINT_ITEM_CLASS = { NULL, /* GetClipVertices */ NULL, /* GetContours */ Coords, - NULL, /* InsertChars */ - NULL, /* DeleteChars */ - NULL, /* Cursor */ - NULL, /* Index */ + InsertChars, + DeleteChars, + TrackCursor, + Index, Part, - NULL, /* Selection */ + Selection, NULL, /* Contour */ ComputeCoordinates, ToArea, |