From 64089dca388f5a9a8235a94b4372763875132219 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Wed, 2 Feb 2000 14:01:15 +0000 Subject: Passage en Zinc --- generic/Text.c | 272 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 136 insertions(+), 136 deletions(-) (limited to 'generic/Text.c') diff --git a/generic/Text.c b/generic/Text.c index 6b0b4d0..b01348b 100644 --- a/generic/Text.c +++ b/generic/Text.c @@ -65,7 +65,7 @@ typedef struct _TextLineInfo { char *start; /* Index of first char in line */ int num_chars; /* Number of displayed chars in line */ - RadarPoint text_origin; /* X pos for drawing the line */ + ZnPoint text_origin; /* X pos for drawing the line */ int width; /* Line width in pixels */ } TextLineInfoStruct, *TextLineInfo; @@ -73,83 +73,83 @@ typedef struct _TextItemStruct { ItemStruct header; /* Public data */ - RadarPoint pos; - RadarAnchor anchor; - RadarAnchor connection_anchor; - RadarColor color; - RadarColor fill_color; + ZnPoint pos; + ZnAnchor anchor; + ZnAnchor connection_anchor; + ZnColor color; + ZnColor fill_color; char *text; Pixmap fill_pattern; - RadarFont font; - RadarJustify alignment; + ZnFont font; + ZnJustify alignment; int width; int spacing; unsigned char flags; /* Private data */ - RadarPoint pos_dev; + ZnPoint pos_dev; int insert_index; int sel_start; int sel_end; - RadarList text_info; + ZnList text_info; int max_width; } TextItemStruct, *TextItem; -static RadarAttrConfig text_attrs[] = { - { RADAR_CONFIG_JUSTIFY, "-alignment", NULL, +static ZnAttrConfig text_attrs[] = { + { ZN_CONFIG_JUSTIFY, "-alignment", NULL, Tk_Offset(TextItemStruct, alignment), 0, - RADAR_COORDS_FLAG|RADAR_LAYOUT_FLAG, False }, - { RADAR_CONFIG_ANCHOR, "-anchor", NULL, - Tk_Offset(TextItemStruct, anchor), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_COLOR, "-color", NULL, - Tk_Offset(TextItemStruct, color), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_BOOL, "-composerotation", NULL, + ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False }, + { ZN_CONFIG_ANCHOR, "-anchor", NULL, + Tk_Offset(TextItemStruct, anchor), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_COLOR, "-color", NULL, + Tk_Offset(TextItemStruct, color), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_BOOL, "-composerotation", NULL, Tk_Offset(TextItemStruct, 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(TextItemStruct, header.flags), COMPOSE_SCALE_BIT, - RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_ITEM, "-connecteditem", NULL, + ZN_COORDS_FLAG, False }, + { ZN_CONFIG_ITEM, "-connecteditem", NULL, Tk_Offset(TextItemStruct, header.connected_item), 0, - RADAR_COORDS_FLAG|RADAR_ITEM_FLAG, False }, - { RADAR_CONFIG_ANCHOR, "-connectionanchor", NULL, - Tk_Offset(TextItemStruct, connection_anchor), 0, RADAR_COORDS_FLAG, False }, - { RADAR_CONFIG_COLOR, "-fillcolor", NULL, - Tk_Offset(TextItemStruct, fill_color), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_PATTERN, "-fillpattern", NULL, - Tk_Offset(TextItemStruct, fill_pattern), 0, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_FONT, "-font", NULL, + ZN_COORDS_FLAG|ZN_ITEM_FLAG, False }, + { ZN_CONFIG_ANCHOR, "-connectionanchor", NULL, + Tk_Offset(TextItemStruct, connection_anchor), 0, ZN_COORDS_FLAG, False }, + { ZN_CONFIG_COLOR, "-fillcolor", NULL, + Tk_Offset(TextItemStruct, fill_color), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_PATTERN, "-fillpattern", NULL, + Tk_Offset(TextItemStruct, fill_pattern), 0, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_FONT, "-font", NULL, Tk_Offset(TextItemStruct, font), 0, - RADAR_COORDS_FLAG|RADAR_LAYOUT_FLAG, False }, - { RADAR_CONFIG_BOOL, "-overstriked", NULL, - Tk_Offset(TextItemStruct, flags), OVERSTRIKED, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_POINT, "-position", NULL, Tk_Offset(TextItemStruct, pos), 0, - RADAR_COORDS_FLAG, False}, - { RADAR_CONFIG_PRI, "-priority", NULL, + ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False }, + { ZN_CONFIG_BOOL, "-overstriked", NULL, + Tk_Offset(TextItemStruct, flags), OVERSTRIKED, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_POINT, "-position", NULL, Tk_Offset(TextItemStruct, pos), 0, + ZN_COORDS_FLAG, False}, + { ZN_CONFIG_PRI, "-priority", NULL, Tk_Offset(TextItemStruct, header.priority), 0, - RADAR_DRAW_FLAG|RADAR_REPICK_FLAG, False }, - { RADAR_CONFIG_BOOL, "-sensitive", NULL, + ZN_DRAW_FLAG|ZN_REPICK_FLAG, False }, + { ZN_CONFIG_BOOL, "-sensitive", NULL, Tk_Offset(TextItemStruct, header.flags), SENSITIVE_BIT, - RADAR_REPICK_FLAG, False }, - { RADAR_CONFIG_DIM, "-spacing", NULL, + ZN_REPICK_FLAG, False }, + { ZN_CONFIG_DIM, "-spacing", NULL, Tk_Offset(TextItemStruct, spacing), 0, - RADAR_COORDS_FLAG|RADAR_LAYOUT_FLAG, False }, - { RADAR_CONFIG_TAGS, "-tags", NULL, + ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False }, + { ZN_CONFIG_TAGS, "-tags", NULL, Tk_Offset(TextItemStruct, header.tags), 0, 0, False }, - { RADAR_CONFIG_TEXT, "-text", NULL, + { ZN_CONFIG_TEXT, "-text", NULL, Tk_Offset(TextItemStruct, text), 0, - RADAR_COORDS_FLAG|RADAR_LAYOUT_FLAG, False }, - { RADAR_CONFIG_BOOL, "-underlined", NULL, - Tk_Offset(TextItemStruct, flags), UNDERLINED, RADAR_DRAW_FLAG, False }, - { RADAR_CONFIG_BOOL, "-visible", NULL, + ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False }, + { ZN_CONFIG_BOOL, "-underlined", NULL, + Tk_Offset(TextItemStruct, flags), UNDERLINED, ZN_DRAW_FLAG, False }, + { ZN_CONFIG_BOOL, "-visible", NULL, Tk_Offset(TextItemStruct, header.flags), VISIBLE_BIT, - RADAR_DRAW_FLAG|RADAR_REPICK_FLAG|RADAR_VIS_FLAG, False }, - { RADAR_CONFIG_INT, "-width", NULL, + ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False }, + { ZN_CONFIG_INT, "-width", NULL, Tk_Offset(TextItemStruct, width), 0, - RADAR_COORDS_FLAG|RADAR_LAYOUT_FLAG, False }, + ZN_COORDS_FLAG|ZN_LAYOUT_FLAG, False }, - { RADAR_CONFIG_END, NULL, NULL, 0, 0, 0 } + { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 } }; @@ -179,12 +179,12 @@ Init(Item item, text->pos.x = text->pos.y = 0.0; text->text = ""; - text->fill_pattern = RadarUnspecifiedPattern; - text->anchor = RadarAnchorNW; - text->connection_anchor = RadarAnchorSW; - text->color = RadarGetColorByValue(wi->win, wi->fore_color); - text->fill_color = RadarGetColorByValue(wi->win, wi->back_color); - text->alignment = RadarJustifyLeft; + text->fill_pattern = ZnUnspecifiedPattern; + text->anchor = ZnAnchorNW; + text->connection_anchor = ZnAnchorSW; + text->color = ZnGetColorByValue(wi->win, wi->fore_color); + text->fill_color = ZnGetColorByValue(wi->win, wi->back_color); + text->alignment = ZnJustifyLeft; text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(wi->font)); text->width = 0; text->spacing = 0; @@ -196,7 +196,7 @@ Init(Item item, CLEAR(text->flags, OVERSTRIKED); CLEAR(text->flags, HAS_FOCUS); - return RADAR_OK; + return ZN_OK; } @@ -215,27 +215,27 @@ Clone(Item item) char *str; if (strlen(text->text) != 0) { - str = RadarMalloc((strlen(text->text) + 1) * sizeof(char)); + str = ZnMalloc((strlen(text->text) + 1) * sizeof(char)); strcpy(str, text->text); text->text = str; } - if (text->fill_pattern != RadarUnspecifiedPattern) { + if (text->fill_pattern != ZnUnspecifiedPattern) { text->fill_pattern = Tk_GetBitmap(wi->interp, wi->win, Tk_NameOfBitmap(wi->dpy, text->fill_pattern)); } - text->color = RadarGetColorByValue(wi->win, text->color); - text->fill_color = RadarGetColorByValue(wi->win, text->fill_color); + text->color = ZnGetColorByValue(wi->win, text->color); + text->fill_color = ZnGetColorByValue(wi->win, text->fill_color); text->font = Tk_GetFont(wi->interp, wi->win, Tk_NameOfFont(text->font)); if (text->text_info) { - text->text_info = RadarListDuplicate(text->text_info); + text->text_info = ZnListDuplicate(text->text_info); } else { /* * Needed in case the layout of the model has not been * done yet. */ - SET(item->inv_flags, RADAR_LAYOUT_FLAG); + SET(item->inv_flags, ZN_LAYOUT_FLAG); } } @@ -254,18 +254,18 @@ Destroy(Item item) TextItem text = (TextItem) item; if (strlen(text->text) != 0) { - RadarFree(text->text); + ZnFree(text->text); } - if (text->fill_pattern != RadarUnspecifiedPattern) { + if (text->fill_pattern != ZnUnspecifiedPattern) { Tk_FreeBitmap(wi->dpy, text->fill_pattern); - text->fill_pattern = RadarUnspecifiedPattern; + text->fill_pattern = ZnUnspecifiedPattern; } - RadarFreeColor(text->color); - RadarFreeColor(text->fill_color); + ZnFreeColor(text->color); + ZnFreeColor(text->fill_color); Tk_FreeFont(text->font); if (text->text_info) { - RadarListFree(text->text_info); + ZnListFree(text->text_info); } } @@ -280,21 +280,21 @@ Destroy(Item item) static int Configure(Item item, int argc, - RadarAttrList argv, + ZnAttrList argv, int *flags) { - Item old_connected; + Item old_connected; old_connected = item->connected_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 (ISSET(*flags, RADAR_ITEM_FLAG)) { + if (ISSET(*flags, ZN_ITEM_FLAG)) { /* * If the new connected item is not appropriate back up * to the old one. */ - if ((item->connected_item == RADAR_NO_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); @@ -304,7 +304,7 @@ Configure(Item item, } } - return RADAR_OK; + return ZN_OK; } @@ -318,13 +318,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; } @@ -337,7 +337,7 @@ Query(Item item, */ static void ComputeCoordinates(Item item, - RadarBool force) + ZnBool force) { WidgetInfo *wi = item->wi; TextItem text = (TextItem) item; @@ -359,19 +359,19 @@ ComputeCoordinates(Item item, * The layout need not be done each time the item is moved, scaled * or rotated. */ - if (ISSET(item->inv_flags, RADAR_LAYOUT_FLAG)) { + if (ISSET(item->inv_flags, ZN_LAYOUT_FLAG)) { char *scan; int wrap, line_index, prev_num_lines; /*printf("layout\n");*/ text->max_width = 0; if (text->text_info != NULL) { - prev_num_lines = RadarListSize(text->text_info); - RadarListEmpty(text->text_info); + prev_num_lines = ZnListSize(text->text_info); + ZnListEmpty(text->text_info); } else { prev_num_lines = 0; - text->text_info = RadarListNew(1, sizeof(TextLineInfoStruct)); + text->text_info = ZnListNew(1, sizeof(TextLineInfoStruct)); } if (text->width > 0) { @@ -416,7 +416,7 @@ ComputeCoordinates(Item item, * It is needed to enable selection and cursor * insertion to behave correctly. */ - RadarListAdd(text->text_info, &info, RadarListTail); + ZnListAdd(text->text_info, &info, ZnListTail); /*printf("adding a line : %s, num_chars : %d, width : %d\n", info.start, info.num_chars, info.width);*/ @@ -433,18 +433,18 @@ ComputeCoordinates(Item item, * in text natural units NOT transformed units. */ cur_dy = fm.ascent; - num_lines = RadarListSize(text->text_info); - infos = (TextLineInfo) RadarListArray(text->text_info); + num_lines = ZnListSize(text->text_info); + infos = (TextLineInfo) ZnListArray(text->text_info); for (i = 0; i < num_lines; i++) { switch (text->alignment) { - case RadarJustifyLeft: + case ZnJustifyLeft: infos[i].text_origin.x = 0; break; - case RadarJustifyCenter: + case ZnJustifyCenter: infos[i].text_origin.x = (text->max_width + 1 - infos[i].width)/2; break; - case RadarJustifyRight: + case ZnJustifyRight: infos[i].text_origin.x = text->max_width + 1 - infos[i].width; break; } @@ -455,20 +455,20 @@ ComputeCoordinates(Item item, } } /* ISSET(item->inv_flags, INV_TEXT_LAYOUT) */ - num_lines = RadarListSize(text->text_info); + num_lines = ZnListSize(text->text_info); height = num_lines * font_height + (num_lines-1) * text->spacing; /* * The connected item support anchors, this is checked by * configure. */ - if (item->connected_item != RADAR_NO_ITEM) { + if (item->connected_item != ZN_NO_ITEM) { item->connected_item->class->GetAnchor(item->connected_item, text->connection_anchor, &text->pos_dev); } else { - RadarTransformPoint(wi->current_transfo, &text->pos, &text->pos_dev); + ZnTransformPoint(wi->current_transfo, &text->pos, &text->pos_dev); } Anchor2Origin(&text->pos_dev, text->max_width, height, text->anchor, @@ -502,24 +502,24 @@ 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) { TextItem text = (TextItem) item; int inside = -1; - RadarBool first_done = False; + ZnBool first_done = False; int num_lines, i; TextLineInfo lines, lines_ptr; Tk_FontMetrics fm; int font_height; - RadarBBox line_bbox; - RadarPoint o; + ZnBBox line_bbox; + ZnPoint o; - lines = (TextLineInfo) RadarListArray(text->text_info); - num_lines = RadarListSize(text->text_info); + lines = (TextLineInfo) ZnListArray(text->text_info); + num_lines = ZnListSize(text->text_info); Tk_GetFontMetrics(text->font, &fm); font_height = fm.descent + fm.ascent; if (text->spacing > 0) { @@ -573,8 +573,8 @@ Draw(Item item) int sel_first_line = -1, sel_last_line = -1, cursor_line = -1; int sel_start_offset, sel_stop_offset, cursor_offset; - lines = (TextLineInfo) RadarListArray(text->text_info); - num_lines = RadarListSize(text->text_info); + lines = (TextLineInfo) ZnListArray(text->text_info); + num_lines = ZnListSize(text->text_info); Tk_GetFontMetrics(text->font, &fm); font_height = fm.ascent+fm.descent; @@ -631,7 +631,7 @@ Draw(Item item) if ((sel_first_line >= 0) && got_selection) { int x, y; - values.foreground = RadarPixel(text->fill_color); + values.foreground = ZnPixel(text->fill_color); values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, GCFillStyle | GCForeground, &values); @@ -663,10 +663,10 @@ Draw(Item item) /* * Setup the gc to render the text and draw it. */ - values.font = RadarFontId(text->font); - values.foreground = RadarPixel(text->color); + values.font = ZnFontId(text->font); + values.foreground = ZnPixel(text->color); gc_mask = GCFont | GCForeground; - if (text->fill_pattern != RadarUnspecifiedPattern) { + if (text->fill_pattern != ZnUnspecifiedPattern) { values.fill_style = FillStippled; values.stipple = text->fill_pattern; gc_mask |= GCFillStyle | GCStipple; @@ -735,12 +735,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)); } @@ -753,7 +753,7 @@ IsSensitive(Item item, */ static double Pick(Item item, - RadarPoint *p, + ZnPoint *p, Item start_item, int aperture, Item *a_item, @@ -765,11 +765,11 @@ Pick(Item item, TextLineInfo lines, lines_ptr; Tk_FontMetrics fm; int font_height; - RadarBBox line_bbox; - RadarPoint o; + ZnBBox line_bbox; + ZnPoint o; - lines = (TextLineInfo) RadarListArray(text->text_info); - num_lines = RadarListSize(text->text_info); + lines = (TextLineInfo) ZnListArray(text->text_info); + num_lines = ZnListSize(text->text_info); dist = 1.0e40; Tk_GetFontMetrics(text->font, &fm); font_height = fm.descent + fm.ascent; @@ -818,8 +818,8 @@ PostScript(Item item, */ static void GetAnchor(Item item, - RadarAnchor anchor, - RadarPoint *p) + ZnAnchor anchor, + ZnPoint *p) { TextItem text = (TextItem) item; @@ -843,13 +843,13 @@ GetAnchor(Item item, * ********************************************************************************** */ -static RadarBool -GetClipVertices(Item item, - RadarPoint **points, - int *num_points) +static ZnBool +GetClipVertices(Item item, + ZnPoint **points, + int *num_points) { - 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; (*points)[0] = item->item_bounding_box.orig; (*points)[1] = item->item_bounding_box.corner; @@ -869,33 +869,33 @@ 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) { TextItem text = (TextItem) item; if ((cmd == COORDS_ADD) || (cmd == COORDS_ADD_LAST) || (cmd == COORDS_REMOVE)) { Tcl_AppendResult(item->wi->interp, " texts can't add or remove vertices", NULL); - return RADAR_ERROR; + return ZN_ERROR; } else if ((cmd == COORDS_REPLACE) || (cmd == COORDS_REPLACE_ALL)) { if (*num_pts == 0) { Tcl_AppendResult(item->wi->interp, " coords command need 1 point on texts", NULL); - return RADAR_ERROR; + return ZN_ERROR; } text->pos = (*pts)[0]; - ITEM.Invalidate(item, RADAR_COORDS_FLAG); + ITEM.Invalidate(item, ZN_COORDS_FLAG); } else if ((cmd == COORDS_READ) || (cmd == COORDS_READ_ALL)) { *num_pts = 1; *pts = &text->pos; } - return RADAR_OK; + return ZN_OK; } @@ -930,4 +930,4 @@ static ItemClassStruct TEXT_ITEM_CLASS = { PostScript }; -RadarItemClassId RadarText = (RadarItemClassId) &TEXT_ITEM_CLASS; +ZnItemClassId ZnText = (ZnItemClassId) &TEXT_ITEM_CLASS; -- cgit v1.1