From b022a3a0a25ccaa28e01c1b0e9bbffe1ffbe8132 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Mon, 8 Apr 2002 13:58:39 +0000 Subject: Modifs suite � la restructuration de Item.c Ajout du support pour edition de texte/selection/curseur dans les fields. --- generic/Track.c | 171 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 125 insertions(+), 46 deletions(-) (limited to 'generic/Track.c') 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, -- cgit v1.1