diff options
Diffstat (limited to 'generic/Tabular.c')
-rw-r--r-- | generic/Tabular.c | 229 |
1 files changed, 115 insertions, 114 deletions
diff --git a/generic/Tabular.c b/generic/Tabular.c index 6e77fa9..cca3b71 100644 --- a/generic/Tabular.c +++ b/generic/Tabular.c @@ -49,15 +49,15 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " ********************************************************************************** */ typedef struct _TabularItemStruct { - ItemStruct header; + ZnItemStruct header; /* Public data */ ZnPoint pos; - ZnAnchor anchor; - ZnAnchor connection_anchor; + Tk_Anchor anchor; + Tk_Anchor connection_anchor; /* Private data */ - FieldSetStruct field_set; + ZnFieldSetStruct field_set; } TabularItemStruct, *TabularItem; @@ -65,13 +65,13 @@ static ZnAttrConfig tabular_attrs[] = { { ZN_CONFIG_ANCHOR, "-anchor", NULL, Tk_Offset(TabularItemStruct, anchor), 0, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BOOL, "-composealpha", NULL, - Tk_Offset(TabularItemStruct, header.flags), COMPOSE_ALPHA_BIT, + Tk_Offset(TabularItemStruct, header.flags), ZN_COMPOSE_ALPHA_BIT, ZN_DRAW_FLAG, False }, { ZN_CONFIG_BOOL, "-composerotation", NULL, - Tk_Offset(TabularItemStruct, header.flags), COMPOSE_ROTATION_BIT, + Tk_Offset(TabularItemStruct, header.flags), ZN_COMPOSE_ROTATION_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_BOOL, "-composescale", NULL, - Tk_Offset(TabularItemStruct, header.flags), COMPOSE_SCALE_BIT, + Tk_Offset(TabularItemStruct, header.flags), ZN_COMPOSE_SCALE_BIT, ZN_COORDS_FLAG, False }, { ZN_CONFIG_ITEM, "-connecteditem", NULL, Tk_Offset(TabularItemStruct, header.connected_item), 0, @@ -89,15 +89,15 @@ static ZnAttrConfig tabular_attrs[] = { Tk_Offset(TabularItemStruct, header.priority), 0, ZN_DRAW_FLAG|ZN_REPICK_FLAG, False }, { ZN_CONFIG_BOOL, "-sensitive", NULL, - Tk_Offset(TabularItemStruct, header.flags), SENSITIVE_BIT, + Tk_Offset(TabularItemStruct, header.flags), ZN_SENSITIVE_BIT, ZN_REPICK_FLAG, False }, { ZN_CONFIG_TAG_LIST, "-tags", NULL, Tk_Offset(TabularItemStruct, header.tags), 0, 0, False }, { ZN_CONFIG_BOOL, "-visible", NULL, - Tk_Offset(TabularItemStruct, header.flags), VISIBLE_BIT, + Tk_Offset(TabularItemStruct, header.flags), ZN_VISIBLE_BIT, ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False }, - { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 } + { ZN_CONFIG_END, NULL, NULL, 0, 0, 0, False } }; @@ -109,24 +109,25 @@ static ZnAttrConfig tabular_attrs[] = { ********************************************************************************** */ static int -Init(Item item, +Init(ZnItem item, int *argc, Tcl_Obj *CONST *args[]) { - WidgetInfo *wi = item->wi; + ZnWInfo *wi = item->wi; TabularItem tab = (TabularItem) item; - FieldSet field_set = &tab->field_set; - - item->priority = DEFAULT_TABULAR_PRIORITY; + ZnFieldSet field_set = &tab->field_set; + int num_fields; + + item->priority = 1; - SET(item->flags, VISIBLE_BIT); - SET(item->flags, SENSITIVE_BIT); - SET(item->flags, COMPOSE_ALPHA_BIT); - SET(item->flags, COMPOSE_SCALE_BIT); - SET(item->flags, COMPOSE_ROTATION_BIT); + SET(item->flags, ZN_VISIBLE_BIT); + SET(item->flags, ZN_SENSITIVE_BIT); + SET(item->flags, ZN_COMPOSE_ALPHA_BIT); + SET(item->flags, ZN_COMPOSE_SCALE_BIT); + SET(item->flags, ZN_COMPOSE_ROTATION_BIT); - tab->anchor = ZnAnchorNW; - tab->connection_anchor = ZnAnchorSW; + tab->anchor = TK_ANCHOR_NW; + tab->connection_anchor = TK_ANCHOR_SW; tab->pos.x = tab->pos.y = 0.0; field_set->item = item; @@ -136,20 +137,20 @@ Init(Item item, * Then try to see if some fields are needed. */ if ((*argc > 0) && (Tcl_GetString((*args)[0])[0] != '-') && - (Tcl_GetIntFromObj(wi->interp, (*args)[0], - &field_set->num_fields) != ZN_ERROR)) { + (Tcl_GetIntFromObj(wi->interp, (*args)[0], &num_fields) != TCL_ERROR)) { + field_set->num_fields = num_fields; *args += 1; *argc -= 1; - FIELD.InitFields(field_set); + ZnFIELD.InitFields(field_set); } else { Tcl_AppendResult(wi->interp, " number of fields expected", NULL); - return ZN_ERROR; + return TCL_ERROR; } item->part_sensitive = 0; - return ZN_OK; + return TCL_OK; } @@ -161,11 +162,11 @@ Init(Item item, ********************************************************************************** */ static void -Clone(Item item) +Clone(ZnItem item) { - FieldSet fs = &((TabularItem) item)->field_set; + ZnFieldSet fs = &((TabularItem) item)->field_set; - FIELD.CloneFields(fs); + ZnFIELD.CloneFields(fs); fs->item = item; } @@ -178,9 +179,9 @@ Clone(Item item) ********************************************************************************** */ static void -Destroy(Item item) +Destroy(ZnItem item) { - FIELD.FreeFields(&((TabularItem) item)->field_set); + ZnFIELD.FreeFields(&((TabularItem) item)->field_set); } @@ -192,17 +193,17 @@ Destroy(Item item) ********************************************************************************** */ static int -Configure(Item item, +Configure(ZnItem item, int argc, Tcl_Obj *CONST argv[], int *flags) { - Item old_connected; + ZnItem old_connected; old_connected = item->connected_item; if (ZnConfigureAttributes(item->wi, item, tabular_attrs, - argc, argv, flags) == ZN_ERROR) { - return ZN_ERROR; + argc, argv, flags) == TCL_ERROR) { + return TCL_ERROR; } if (ISSET(*flags, ZN_ITEM_FLAG)) { /* @@ -212,14 +213,14 @@ Configure(Item item, if ((item->connected_item == ZN_NO_ITEM) || (item->connected_item->class->has_anchors && (item->parent == item->connected_item->parent))) { - ITEM.UpdateItemDependency(item, old_connected); + ZnITEM.UpdateItemDependency(item, old_connected); } else { item->connected_item = old_connected; } } - return ZN_OK; + return TCL_OK; } @@ -231,15 +232,15 @@ Configure(Item item, ********************************************************************************** */ static int -Query(Item item, - int argc, +Query(ZnItem item, + int argc __unused, Tcl_Obj *CONST argv[]) { - if (ZnQueryAttribute(item->wi, item, tabular_attrs, argv[0]) == ZN_ERROR) { - return ZN_ERROR; + if (ZnQueryAttribute(item->wi, item, tabular_attrs, argv[0]) == TCL_ERROR) { + return TCL_ERROR; } - return ZN_OK; + return TCL_OK; } @@ -251,17 +252,17 @@ Query(Item item, ********************************************************************************** */ static void -ComputeCoordinates(Item item, - ZnBool force) +ComputeCoordinates(ZnItem item, + ZnBool force __unused) { TabularItem tab = (TabularItem) item; - WidgetInfo *wi = item->wi; - FieldSet field_set = &tab->field_set; + ZnWInfo *wi = item->wi; + ZnFieldSet field_set = &tab->field_set; ZnDim width, height; - ResetBBox(&item->item_bounding_box); + ZnResetBBox(&item->item_bounding_box); if (field_set->label_format && field_set->num_fields) { - FIELD.GetLabelBBox(field_set, &width, &height); + ZnFIELD.GetLabelBBox(field_set, &width, &height); /* * The connected item support anchors, this is checked by @@ -277,8 +278,8 @@ ComputeCoordinates(Item item, &field_set->label_pos); } - Anchor2Origin(&field_set->label_pos, width, height, tab->anchor, - &field_set->label_pos); + ZnAnchor2Origin(&field_set->label_pos, width, height, tab->anchor, + &field_set->label_pos); /* * Setup the item bounding box. @@ -290,7 +291,7 @@ ComputeCoordinates(Item item, /* * Update connected items. */ - SET(item->flags, UPDATE_DEPENDENT_BIT); + SET(item->flags, ZN_UPDATE_DEPENDENT_BIT); } } @@ -305,10 +306,10 @@ ComputeCoordinates(Item item, ********************************************************************************** */ static int -ToArea(Item item, +ToArea(ZnItem item, ZnToArea ta) { - return FIELD.FieldsToArea(&((TabularItem) item)->field_set, ta->area); + return ZnFIELD.FieldsToArea(&((TabularItem) item)->field_set, ta->area); } @@ -320,9 +321,9 @@ ToArea(Item item, ********************************************************************************** */ static void -Draw(Item item) +Draw(ZnItem item) { - FIELD.DrawFields(&((TabularItem) item)->field_set); + ZnFIELD.DrawFields(&((TabularItem) item)->field_set); } @@ -334,9 +335,9 @@ Draw(Item item) ********************************************************************************** */ static void -Render(Item item) +Render(ZnItem item) { - FIELD.RenderFields(&((TabularItem) item)->field_set); + ZnFIELD.RenderFields(&((TabularItem) item)->field_set); } @@ -348,18 +349,18 @@ Render(Item item) ********************************************************************************** */ static ZnBool -IsSensitive(Item item, +IsSensitive(ZnItem item, int item_part) { - if (ISCLEAR(item->flags, SENSITIVE_BIT) || + if (ISCLEAR(item->flags, ZN_SENSITIVE_BIT) || !item->parent->class->IsSensitive(item->parent, ZN_NO_PART)) { return False; } if (item_part == ZN_NO_PART) { - return ISSET(item->flags, SENSITIVE_BIT); + return ISSET(item->flags, ZN_SENSITIVE_BIT); } else { - return FIELD.IsFieldSensitive(&((TabularItem) item)->field_set, item_part); + return ZnFIELD.IsFieldSensitive(&((TabularItem) item)->field_set, item_part); } } @@ -373,13 +374,13 @@ IsSensitive(Item item, ********************************************************************************** */ static double -Pick(Item item, +Pick(ZnItem item, ZnPick ps) { int best_part; double dist; - dist = FIELD.FieldsPick(&((TabularItem) item)->field_set, ps->point, &best_part); + dist = ZnFIELD.FieldsPick(&((TabularItem) item)->field_set, ps->point, &best_part); /*printf("tabular %d reporting part %d, distance %lf\n", item->id, best_part, dist);*/ if (dist <= 0.0) { @@ -399,8 +400,8 @@ Pick(Item item, ********************************************************************************** */ static void -PostScript(Item item, - PostScriptInfo ps_info) +PostScript(ZnItem item __unused, + ZnPostScriptInfo ps_info __unused) { } @@ -412,8 +413,8 @@ PostScript(Item item, * ********************************************************************************** */ -static FieldSet -GetFieldSet(Item item) +static ZnFieldSet +GetFieldSet(ZnItem item) { return &((TabularItem) item)->field_set; } @@ -427,16 +428,16 @@ GetFieldSet(Item item) ********************************************************************************** */ static void -GetAnchor(Item item, - ZnAnchor anchor, +GetAnchor(ZnItem item, + Tk_Anchor anchor, ZnPoint *p) { - FieldSet field_set = &((TabularItem) item)->field_set; + ZnFieldSet field_set = &((TabularItem) item)->field_set; ZnDim width, height; if (field_set->label_format) { - FIELD.GetLabelBBox(field_set, &width, &height); - Origin2Anchor(&field_set->label_pos, width, height, anchor, p); + ZnFIELD.GetLabelBBox(field_set, &width, &height); + ZnOrigin2Anchor(&field_set->label_pos, width, height, anchor, p); } else { p->x = p->y = 0.0; @@ -449,23 +450,23 @@ GetAnchor(Item item, * * GetClipVertices -- * Get the clipping shape. - * Never ever call TRI_FREE on the tristrip returned by GetClipVertices. + * Never ever call ZnTriFree on the tristrip returned by GetClipVertices. * ********************************************************************************** */ static ZnBool -GetClipVertices(Item item, +GetClipVertices(ZnItem item, ZnTriStrip *tristrip) { - FieldSet field_set = &((TabularItem) item)->field_set; + ZnFieldSet field_set = &((TabularItem) item)->field_set; ZnDim width, height; ZnPoint *points; if (field_set->label_format) { - FIELD.GetLabelBBox(field_set, &width, &height); + ZnFIELD.GetLabelBBox(field_set, &width, &height); ZnListAssertSize(item->wi->work_pts, 2); points = (ZnPoint *) ZnListArray(item->wi->work_pts); - TRI_STRIP1(tristrip, points, 2, False); + ZnTriStrip1(tristrip, points, 2, False); points[0] = field_set->label_pos; points[1].x = points[0].x + width; points[1].y = points[0].y + height; @@ -486,35 +487,35 @@ GetClipVertices(Item item, ********************************************************************************** */ static int -Coords(Item item, - int contour, - int index, - int cmd, - ZnPoint **pts, - char **controls, - int *num_pts) +Coords(ZnItem item, + int contour __unused, + int index __unused, + int cmd, + ZnPoint **pts, + char **controls __unused, + unsigned int *num_pts) { TabularItem tabular = (TabularItem) item; - if ((cmd == COORDS_ADD) || (cmd == COORDS_ADD_LAST) || (cmd == COORDS_REMOVE)) { + if ((cmd == ZN_COORDS_ADD) || (cmd == ZN_COORDS_ADD_LAST) || (cmd == ZN_COORDS_REMOVE)) { Tcl_AppendResult(item->wi->interp, " tabulars can't add or remove vertices", NULL); - return ZN_ERROR; + return TCL_ERROR; } - else if ((cmd == COORDS_REPLACE) || (cmd == COORDS_REPLACE_ALL)) { + else if ((cmd == ZN_COORDS_REPLACE) || (cmd == ZN_COORDS_REPLACE_ALL)) { if (*num_pts == 0) { Tcl_AppendResult(item->wi->interp, " coords command need 1 point on tabulars", NULL); - return ZN_ERROR; + return TCL_ERROR; } tabular->pos = (*pts)[0]; - ITEM.Invalidate(item, ZN_COORDS_FLAG); + ZnITEM.Invalidate(item, ZN_COORDS_FLAG); } - else if ((cmd == COORDS_READ) || (cmd == COORDS_READ_ALL)) { + else if ((cmd == ZN_COORDS_READ) || (cmd == ZN_COORDS_READ_ALL)) { *num_pts = 1; *pts = &tabular->pos; } - return ZN_OK; + return TCL_OK; } @@ -527,7 +528,7 @@ Coords(Item item, ********************************************************************************** */ static int -Part(Item item, +Part(ZnItem item, Tcl_Obj **part_spec, int *part) { @@ -542,14 +543,14 @@ Part(Item item, else if (isdigit(part_str[0])) { *part = strtol(part_str, &end, 0); if ((*end != 0) || (*part < 0) || - (*part >= ((TabularItem) item)->field_set.num_fields)) { + ((unsigned int) *part >= ((TabularItem) item)->field_set.num_fields)) { goto part_error; } } else { part_error: Tcl_AppendResult(item->wi->interp, " invalid item part specification", NULL); - return ZN_ERROR; + return TCL_ERROR; } } else { @@ -557,10 +558,10 @@ Part(Item item, *part_spec = Tcl_NewIntObj(*part); } else { - *part_spec = NewStringObj(""); + *part_spec = Tcl_NewStringObj("", -1); } } - return ZN_OK; + return TCL_OK; } @@ -574,12 +575,12 @@ Part(Item item, ********************************************************************************** */ static int -Index(Item item, +Index(ZnItem item, int field, Tcl_Obj *index_spec, int *index) { - return FIELD.FieldIndex(&((TabularItem) item)->field_set, field, + return ZnFIELD.FieldIndex(&((TabularItem) item)->field_set, field, index_spec, index); } @@ -592,14 +593,14 @@ Index(Item item, ********************************************************************************** */ static void -InsertChars(Item item, +InsertChars(ZnItem item, int field, int *index, char *chars) { - if (FIELD.FieldInsertChars(&((TabularItem) item)->field_set, + if (ZnFIELD.FieldInsertChars(&((TabularItem) item)->field_set, field, index, chars)) { - ITEM.Invalidate(item, ZN_COORDS_FLAG); + ZnITEM.Invalidate(item, ZN_COORDS_FLAG); } } @@ -612,14 +613,14 @@ InsertChars(Item item, ********************************************************************************** */ static void -DeleteChars(Item item, +DeleteChars(ZnItem item, int field, int *first, int *last) { - if (FIELD.FieldDeleteChars(&((TabularItem) item)->field_set, + if (ZnFIELD.FieldDeleteChars(&((TabularItem) item)->field_set, field, first, last)) { - ITEM.Invalidate(item, ZN_COORDS_FLAG); + ZnITEM.Invalidate(item, ZN_COORDS_FLAG); } } @@ -632,11 +633,11 @@ DeleteChars(Item item, ********************************************************************************** */ static void -TabularCursor(Item item, +TabularCursor(ZnItem item, int field, int index) { - FIELD.FieldCursor(&((TabularItem) item)->field_set, field, index); + ZnFIELD.FieldCursor(&((TabularItem) item)->field_set, field, index); } @@ -648,13 +649,13 @@ TabularCursor(Item item, ********************************************************************************** */ static int -Selection(Item item, - int field, - int offset, - char *chars, - int max_chars) +Selection(ZnItem item, + int field, + int offset, + char *chars, + int max_chars) { - return FIELD.FieldSelection(&((TabularItem) item)->field_set, field, + return ZnFIELD.FieldSelection(&((TabularItem) item)->field_set, field, offset, chars, max_chars); } @@ -666,7 +667,7 @@ Selection(Item item, * ********************************************************************************** */ -static ItemClassStruct TABULAR_ITEM_CLASS = { +static ZnItemClassStruct TABULAR_ITEM_CLASS = { sizeof(TabularItemStruct), 0, /* num_parts */ True, /* has_anchors */ |