diff options
author | lecoanet | 2005-04-13 14:07:59 +0000 |
---|---|---|
committer | lecoanet | 2005-04-13 14:07:59 +0000 |
commit | 46ea8bc12e435b7ca6593bc43498ef6aae3e261a (patch) | |
tree | 999a9e3b04ec40156befba0c189c83d07aac4cfa /generic/Field.c | |
parent | 970957ef4d39e8558410347852b709cf8fd15e87 (diff) | |
download | tkzinc-46ea8bc12e435b7ca6593bc43498ef6aae3e261a.zip tkzinc-46ea8bc12e435b7ca6593bc43498ef6aae3e261a.tar.gz tkzinc-46ea8bc12e435b7ca6593bc43498ef6aae3e261a.tar.bz2 tkzinc-46ea8bc12e435b7ca6593bc43498ef6aae3e261a.tar.xz |
Expanded the tabs into spaces to make the indenting independant of
the editing environment (emacs vs vi for example).
Diffstat (limited to 'generic/Field.c')
-rw-r--r-- | generic/Field.c | 1240 |
1 files changed, 620 insertions, 620 deletions
diff --git a/generic/Field.c b/generic/Field.c index 5ff53e0..9519d67 100644 --- a/generic/Field.c +++ b/generic/Field.c @@ -1,8 +1,8 @@ /* * Field.c -- Implementation of fields. * - * Authors : Patrick Lecoanet. - * Creation date : + * Authors : Patrick Lecoanet. + * Creation date : * * $Id$ */ @@ -42,11 +42,11 @@ static const char rcsid[] = "$Id$"; static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " $"; -#define FIELD_SENSITIVE_BIT 1 -#define FIELD_VISIBLE_BIT 2 -#define FILLED_BIT 4 -#define TEXT_ON_TOP_BIT 8 -#define CACHE_OK 16 +#define FIELD_SENSITIVE_BIT 1 +#define FIELD_VISIBLE_BIT 2 +#define FILLED_BIT 4 +#define TEXT_ON_TOP_BIT 8 +#define CACHE_OK 16 /* @@ -54,30 +54,30 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ " */ typedef struct _FieldStruct { /* Public data */ - ZnGradient *color; - ZnGradient *fill_color; - ZnGradient *border_color; - char *text; - ZnImage image; - ZnImage tile; - Tk_Font font; + ZnGradient *color; + ZnGradient *fill_color; + ZnGradient *border_color; + char *text; + ZnImage image; + ZnImage tile; + Tk_Font font; unsigned short flags; - ZnBorder border_edges; - Tk_Justify alignment; - ZnReliefStyle relief; - ZnDim relief_thickness; - ZnAutoAlign auto_alignment; + ZnBorder border_edges; + Tk_Justify alignment; + ZnReliefStyle relief; + ZnDim relief_thickness; + ZnAutoAlign auto_alignment; /* Private data */ - ZnGradient *gradient; - ZnPoint *grad_geo; - short orig_x; - short orig_y; - short corner_x; - short corner_y; - int insert_index; + ZnGradient *gradient; + ZnPoint *grad_geo; + short orig_x; + short orig_y; + short corner_x; + short corner_y; + int insert_index; #ifdef GL - ZnTexFontInfo *tfi; + ZnTexFontInfo *tfi; #endif } FieldStruct, *Field; @@ -87,7 +87,7 @@ typedef struct _FieldStruct { * -filled attributes set the ZN_COORDS_FLAG to update * the leader that might protude if not clipped by the text. */ -ZnAttrConfig field_attrs[] = { +ZnAttrConfig field_attrs[] = { { ZN_CONFIG_ALIGNMENT, "-alignment", NULL, Tk_Offset(FieldStruct, alignment), 0, ZN_DRAW_FLAG, False }, { ZN_CONFIG_AUTO_ALIGNMENT, "-autoalignment", NULL, @@ -128,7 +128,7 @@ ZnAttrConfig field_attrs[] = { { ZN_CONFIG_END, NULL, NULL, 0, 0, 0, False } }; -static void GetLabelBBox(ZnFieldSet field_set, ZnDim *w, ZnDim *h); +static void GetLabelBBox(ZnFieldSet field_set, ZnDim *w, ZnDim *h); @@ -136,23 +136,23 @@ static void GetLabelBBox(ZnFieldSet field_set, ZnDim *w, ZnDim *h); ********************************************************************************** * * ComputeFieldAttachment -- - * Compute the location/size of the field, computing attachments if any. + * Compute the location/size of the field, computing attachments if any. * ********************************************************************************** */ static void -ComputeFieldAttachment(ZnFieldSet field_set, - unsigned int field, - ZnBBox *field_bbox) +ComputeFieldAttachment(ZnFieldSet field_set, + unsigned int field, + ZnBBox *field_bbox) { - ZnBBox ref_bbox; - ZnDim real_width, real_height; - unsigned int ref_field, num_fields; - char x_attach, y_attach, x_dim, y_dim; - short width_spec, height_spec; - int x_spec, y_spec, icon_width=0, icon_height=0; - Field fptr; + ZnBBox ref_bbox; + ZnDim real_width, real_height; + unsigned int ref_field, num_fields; + char x_attach, y_attach, x_dim, y_dim; + short width_spec, height_spec; + int x_spec, y_spec, icon_width=0, icon_height=0; + Field fptr; Tk_FontMetrics fm; /*printf("ComputeFieldAttachment in\n");*/ @@ -178,8 +178,8 @@ ComputeFieldAttachment(ZnFieldSet field_set, num_fields = ZnLFNumFields(field_set->label_format); ZnLFGetField(field_set->label_format, field, - &x_attach, &y_attach, &x_dim, &y_dim, - &x_spec, &y_spec, &width_spec, &height_spec); + &x_attach, &y_attach, &x_dim, &y_dim, + &x_spec, &y_spec, &width_spec, &height_spec); /* * First try to compute the field size which may be a factor @@ -200,29 +200,29 @@ ComputeFieldAttachment(ZnFieldSet field_set, break; case ZN_LF_DIM_AUTO: { - int len = 0; - ZnDim text_width; + int len = 0; + ZnDim text_width; if (fptr->text) { - len = strlen(fptr->text); + len = strlen(fptr->text); } real_width = 0.0; if (fptr->image != ZnUnspecifiedImage) { - real_width = (ZnDim) icon_width; + real_width = (ZnDim) icon_width; } if (len) { - /* - * The 4 extra pixels are needed for border and padding. - */ - text_width = (ZnDim) Tk_TextWidth(fptr->font, fptr->text, len) + 4; - real_width = text_width < real_width ? real_width : text_width; + /* + * The 4 extra pixels are needed for border and padding. + */ + text_width = (ZnDim) Tk_TextWidth(fptr->font, fptr->text, len) + 4; + real_width = text_width < real_width ? real_width : text_width; } real_width += (ZnDim) width_spec; break; } case ZN_LF_DIM_LABEL: { - ZnDim lh; + ZnDim lh; GetLabelBBox(field_set, &real_width, &lh); break; @@ -246,23 +246,23 @@ ComputeFieldAttachment(ZnFieldSet field_set, break; case ZN_LF_DIM_AUTO: { - ZnDim text_height; + ZnDim text_height; real_height = 0.0; if (fptr->image != ZnUnspecifiedImage) { - real_height = (ZnDim) icon_height; + real_height = (ZnDim) icon_height; } if (fptr->text && strlen(fptr->text)) { - Tk_GetFontMetrics(fptr->font, &fm); - text_height = (ZnDim) (fm.ascent + fm.descent); - real_height = text_height < real_height ? real_height : text_height; + Tk_GetFontMetrics(fptr->font, &fm); + text_height = (ZnDim) (fm.ascent + fm.descent); + real_height = text_height < real_height ? real_height : text_height; } real_height += (ZnDim) height_spec; break; } case ZN_LF_DIM_LABEL: { - ZnDim lw; + ZnDim lw; GetLabelBBox(field_set, &lw, &real_height); break; @@ -300,43 +300,43 @@ ComputeFieldAttachment(ZnFieldSet field_set, ref_field = x_spec; field_bbox->orig.x = field_bbox->corner.x = 0; if (ref_field >= num_fields) { - ZnWarning ("Attached (x) to an inexistant field geometry\n"); + ZnWarning ("Attached (x) to an inexistant field geometry\n"); } else { - ComputeFieldAttachment(field_set, ref_field, &ref_bbox); - switch (x_attach) { - case ZN_LF_ATTACH_FWD: - if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { - field_bbox->orig.x = ref_bbox.corner.x; - } - else { - field_bbox->orig.x = ref_bbox.orig.x; - } - field_bbox->corner.x = field_bbox->orig.x + real_width; - break; - case ZN_LF_ATTACH_BWD: - if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { - field_bbox->corner.x = ref_bbox.orig.x; - } - else { - field_bbox->corner.x = ref_bbox.corner.x; - } - field_bbox->orig.x = field_bbox->corner.x - real_width; - break; - case ZN_LF_ATTACH_LEFT: - field_bbox->orig.x = ref_bbox.orig.x; - field_bbox->corner.x = field_bbox->orig.x + real_width; - break; - case ZN_LF_ATTACH_RIGHT: - if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { - field_bbox->corner.x = ref_bbox.corner.x; - } - else { - field_bbox->corner.x = ref_bbox.orig.x; - } - field_bbox->orig.x = field_bbox->corner.x - real_width; - break; - } + ComputeFieldAttachment(field_set, ref_field, &ref_bbox); + switch (x_attach) { + case ZN_LF_ATTACH_FWD: + if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { + field_bbox->orig.x = ref_bbox.corner.x; + } + else { + field_bbox->orig.x = ref_bbox.orig.x; + } + field_bbox->corner.x = field_bbox->orig.x + real_width; + break; + case ZN_LF_ATTACH_BWD: + if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { + field_bbox->corner.x = ref_bbox.orig.x; + } + else { + field_bbox->corner.x = ref_bbox.corner.x; + } + field_bbox->orig.x = field_bbox->corner.x - real_width; + break; + case ZN_LF_ATTACH_LEFT: + field_bbox->orig.x = ref_bbox.orig.x; + field_bbox->corner.x = field_bbox->orig.x + real_width; + break; + case ZN_LF_ATTACH_RIGHT: + if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { + field_bbox->corner.x = ref_bbox.corner.x; + } + else { + field_bbox->corner.x = ref_bbox.orig.x; + } + field_bbox->orig.x = field_bbox->corner.x - real_width; + break; + } } } /*printf("field %d, x = %g\n", field, field_bbox->orig.x);*/ @@ -354,43 +354,43 @@ ComputeFieldAttachment(ZnFieldSet field_set, ref_field = y_spec; field_bbox->orig.y = field_bbox->corner.y = 0; if (ref_field >= num_fields) { - ZnWarning ("Attached (y) to an inexistant field geometry\n"); + ZnWarning ("Attached (y) to an inexistant field geometry\n"); } else { - ComputeFieldAttachment(field_set, ref_field, &ref_bbox); - switch (y_attach) { - case ZN_LF_ATTACH_FWD: - if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { - field_bbox->orig.y = ref_bbox.corner.y; - } - else { - field_bbox->orig.y = ref_bbox.orig.y; - } - field_bbox->corner.y = field_bbox->orig.y + real_height; - break; - case ZN_LF_ATTACH_BWD: - if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { - field_bbox->corner.y = ref_bbox.orig.y; - } - else { - field_bbox->corner.y = ref_bbox.corner.y; - } - field_bbox->orig.y = field_bbox->corner.y - real_height; - break; - case ZN_LF_ATTACH_LEFT: - field_bbox->orig.y = ref_bbox.orig.y; - field_bbox->corner.y = field_bbox->orig.y + real_height; - break; - case ZN_LF_ATTACH_RIGHT: - if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { - field_bbox->corner.y = ref_bbox.corner.y; - } - else { - field_bbox->corner.y = ref_bbox.orig.y; - } - field_bbox->orig.y = field_bbox->corner.y - real_height; - break; - } + ComputeFieldAttachment(field_set, ref_field, &ref_bbox); + switch (y_attach) { + case ZN_LF_ATTACH_FWD: + if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { + field_bbox->orig.y = ref_bbox.corner.y; + } + else { + field_bbox->orig.y = ref_bbox.orig.y; + } + field_bbox->corner.y = field_bbox->orig.y + real_height; + break; + case ZN_LF_ATTACH_BWD: + if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { + field_bbox->corner.y = ref_bbox.orig.y; + } + else { + field_bbox->corner.y = ref_bbox.corner.y; + } + field_bbox->orig.y = field_bbox->corner.y - real_height; + break; + case ZN_LF_ATTACH_LEFT: + field_bbox->orig.y = ref_bbox.orig.y; + field_bbox->corner.y = field_bbox->orig.y + real_height; + break; + case ZN_LF_ATTACH_RIGHT: + if (ISSET(field_set->fields[ref_field].flags, FIELD_VISIBLE_BIT)) { + field_bbox->corner.y = ref_bbox.corner.y; + } + else { + field_bbox->corner.y = ref_bbox.orig.y; + } + field_bbox->orig.y = field_bbox->corner.y - real_height; + break; + } } } /*printf("field %d, y = %g\n", field, field_bbox->orig.y);*/ @@ -410,21 +410,21 @@ ComputeFieldAttachment(ZnFieldSet field_set, ********************************************************************************** * * ClearFieldCache -- - * Reset the geometric cache of all fields depending on a given field (or - * of all fields if the field is < 0). Clear also the label bounding box - * cache if some action has been taken on a field. + * Reset the geometric cache of all fields depending on a given field (or + * of all fields if the field is < 0). Clear also the label bounding box + * cache if some action has been taken on a field. * ********************************************************************************** */ static void -ClearFieldCache(ZnFieldSet field_set, - int field) +ClearFieldCache(ZnFieldSet field_set, + int field) { - unsigned int i, num_fields; - ZnBool clear_bbox; - int x_spec, y_spec; - char x_attach, y_attach, x_dim, y_dim; - short width_spec, height_spec; + unsigned int i, num_fields; + ZnBool clear_bbox; + int x_spec, y_spec; + char x_attach, y_attach, x_dim, y_dim; + short width_spec, height_spec; if (!field_set->num_fields) { return; @@ -446,31 +446,31 @@ ClearFieldCache(ZnFieldSet field_set, return; } ZnLFGetField(field_set->label_format, (unsigned int) field, - &x_attach, &y_attach, &x_dim, &y_dim, - &x_spec, &y_spec, &width_spec, &height_spec); + &x_attach, &y_attach, &x_dim, &y_dim, + &x_spec, &y_spec, &width_spec, &height_spec); if ((x_dim != ZN_LF_DIM_PIXEL) || (y_dim != ZN_LF_DIM_PIXEL)) { CLEAR(field_set->fields[field].flags, CACHE_OK); clear_bbox = True; } for (i = 0; i < num_fields; i++) { ZnLFGetField(field_set->label_format, i, - &x_attach, &y_attach, &x_dim, &y_dim, - &x_spec, &y_spec, &width_spec, &height_spec); + &x_attach, &y_attach, &x_dim, &y_dim, + &x_spec, &y_spec, &width_spec, &height_spec); if ((x_attach == ZN_LF_ATTACH_PIXEL) && (y_attach == ZN_LF_ATTACH_PIXEL)) { continue; } if (x_attach != ZN_LF_ATTACH_PIXEL) { if ((x_spec == field) && ISSET(field_set->fields[i].flags, CACHE_OK)) { - CLEAR(field_set->fields[i].flags, CACHE_OK); - ClearFieldCache(field_set, (int) i); - clear_bbox = True; + CLEAR(field_set->fields[i].flags, CACHE_OK); + ClearFieldCache(field_set, (int) i); + clear_bbox = True; } } if (y_attach != ZN_LF_ATTACH_PIXEL) { if ((y_spec == field) && ISSET(field_set->fields[i].flags, CACHE_OK)) { - CLEAR(field_set->fields[i].flags, CACHE_OK); - ClearFieldCache(field_set, (int) i); - clear_bbox = True; + CLEAR(field_set->fields[i].flags, CACHE_OK); + ClearFieldCache(field_set, (int) i); + clear_bbox = True; } } } @@ -489,14 +489,14 @@ ClearFieldCache(ZnFieldSet field_set, ********************************************************************************** */ static void -GetLabelBBox(ZnFieldSet field_set, - ZnDim *w, - ZnDim *h) +GetLabelBBox(ZnFieldSet field_set, + ZnDim *w, + ZnDim *h) { - ZnBBox bbox, tmp_bbox; - ZnLabelFormat lf; - unsigned int i, num_fields; - ZnDim clip_w, clip_h; + ZnBBox bbox, tmp_bbox; + ZnLabelFormat lf; + unsigned int i, num_fields; + ZnDim clip_w, clip_h; /*printf("GetLabelBBox in\n");*/ if ((field_set->label_width >= 0.0) && (field_set->label_height >= 0.0)) { @@ -525,7 +525,7 @@ GetLabelBBox(ZnFieldSet field_set, field_set->label_height = bbox.corner.y; /*printf("GetLabelBBox size before clipping; w = %g, h = %g\n", - field_set->label_width, field_set->label_height);*/ + field_set->label_width, field_set->label_height);*/ if (ZnLFGetClipBox(lf, &clip_w, &clip_h)) { if (clip_w < field_set->label_width) { field_set->label_width = clip_w; @@ -545,17 +545,17 @@ GetLabelBBox(ZnFieldSet field_set, ********************************************************************************** * * GetFieldBBox -- - * Compute the location of the field described - * by the field entry index in the item current LabelFormat. + * Compute the location of the field described + * by the field entry index in the item current LabelFormat. * ********************************************************************************** */ static void -GetFieldBBox(ZnFieldSet field_set, - unsigned int index, - ZnBBox *field_bbox) +GetFieldBBox(ZnFieldSet field_set, + unsigned int index, + ZnBBox *field_bbox) { - ZnReal ox, oy; + ZnReal ox, oy; /*printf("GetFieldBBox in\n");*/ if (field_set->label_format) { @@ -578,20 +578,20 @@ GetFieldBBox(ZnFieldSet field_set, ********************************************************************************** * * ComputeFieldTextLocation -- - * Compute the position of the text in a field. This is a position - * that we can give to XDrawText. The position is deduced from the - * field bounding box passed in bbox. - * Return also the text bounding box. + * Compute the position of the text in a field. This is a position + * that we can give to XDrawText. The position is deduced from the + * field bounding box passed in bbox. + * Return also the text bounding box. * ********************************************************************************** */ static void -ComputeFieldTextLocation(Field fptr, - ZnBBox *bbox, - ZnPoint *pos, - ZnBBox *text_bbox) +ComputeFieldTextLocation(Field fptr, + ZnBBox *bbox, + ZnPoint *pos, + ZnBBox *text_bbox) { - ZnDim w, h; + ZnDim w, h; Tk_FontMetrics fm; Tk_GetFontMetrics(fptr->font, &fm); @@ -624,30 +624,30 @@ ComputeFieldTextLocation(Field fptr, ********************************************************************************** * * LeaderToLabel -- - * Compute the segment part of segment <start, end> that lies - * outside the fields of item. + * Compute the segment part of segment <start, end> that lies + * outside the fields of item. * ********************************************************************************** */ static void -LeaderToLabel(ZnFieldSet field_set, - ZnPoint *start, - ZnPoint *end) +LeaderToLabel(ZnFieldSet field_set, + ZnPoint *start, + ZnPoint *end) { - int b_num; - ZnPoint delta, inf, sup; - ZnPos xt=0, yu=0, yw=0, xv=0; - Field fptr; - unsigned int i; - ZnBBox field_bbox; - - /* Intersection points : */ - /* T |xt / delta_y U |x1 V |y1 W |yw / delta_x */ - /* |y2 |yu / delta_x |xv / delta_y |x2 */ - /* */ - /* y = ax + b; */ - /* a = delta_y / delta_x */ - /* b = (y * delta_x - x * delta_y) / delta_x */ + int b_num; + ZnPoint delta, inf, sup; + ZnPos xt=0, yu=0, yw=0, xv=0; + Field fptr; + unsigned int i; + ZnBBox field_bbox; + + /* Intersection points : */ + /* T |xt / delta_y U |x1 V |y1 W |yw / delta_x */ + /* |y2 |yu / delta_x |xv / delta_y |x2 */ + /* */ + /* y = ax + b; */ + /* a = delta_y / delta_x */ + /* b = (y * delta_x - x * delta_y) / delta_x */ delta.x = start->x - end->x; delta.y = start->y - end->y; @@ -660,11 +660,11 @@ LeaderToLabel(ZnFieldSet field_set, * its own, don't clip. */ if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT) || - (!fptr->text && - ISCLEAR(fptr->flags, FILLED_BIT) && - (fptr->border_edges == ZN_NO_BORDER) && - (fptr->relief == ZN_RELIEF_FLAT) && - (fptr->image == ZnUnspecifiedImage))) { + (!fptr->text && + ISCLEAR(fptr->flags, FILLED_BIT) && + (fptr->border_edges == ZN_NO_BORDER) && + (fptr->relief == ZN_RELIEF_FLAT) && + (fptr->image == ZnUnspecifiedImage))) { continue; } @@ -678,12 +678,12 @@ LeaderToLabel(ZnFieldSet field_set, * important when there are leading and trailing spaces. */ if (fptr->text && - ISCLEAR(fptr->flags, FILLED_BIT) && - (fptr->border_edges == ZN_NO_BORDER) && - (fptr->relief == ZN_RELIEF_FLAT) && - (fptr->image == ZnUnspecifiedImage)) { + ISCLEAR(fptr->flags, FILLED_BIT) && + (fptr->border_edges == ZN_NO_BORDER) && + (fptr->relief == ZN_RELIEF_FLAT) && + (fptr->image == ZnUnspecifiedImage)) { ZnBBox text_bbox; - ZnPoint text_pos; /* dummy */ + ZnPoint text_pos; /* dummy */ int space_width; int scan_forw, scan_back; space_width = Tk_TextWidth(fptr->font, " ", 1); @@ -694,7 +694,7 @@ LeaderToLabel(ZnFieldSet field_set, * * PLC: IMHO, this is to compensate for exotic fonts like 'symbolesATC'. * I am not planning to port this to Tk for two reasons: - * 1/ Current positions are no longer implemented as characters + * 1/ Current positions are no longer implemented as characters * and 2/ Tk does not give access (easily) to lbearings and rbearings. * This patch has been contributed by Phidias team. I don't know the * problem it was meant to solve. @@ -706,23 +706,23 @@ LeaderToLabel(ZnFieldSet field_set, */ scan_forw = 0; while (fptr->text[scan_forw] == ' ') { - /* leading spaces */ - text_bbox.orig.x += space_width; - scan_forw++; + /* leading spaces */ + text_bbox.orig.x += space_width; + scan_forw++; } /* * Empty text. */ if (!fptr->text || (fptr->text[scan_forw] == 0)) { - continue; + continue; } scan_back = strlen(fptr->text)-1; while ((fptr->text[scan_back] == ' ') && (scan_back > scan_forw)) { - /* trailing spaces */ - text_bbox.corner.x -= space_width; - scan_back--; + /* trailing spaces */ + text_bbox.corner.x -= space_width; + scan_back--; } field_bbox = text_bbox; @@ -733,7 +733,7 @@ LeaderToLabel(ZnFieldSet field_set, } if ((start->x >= field_bbox.orig.x) && (start->x < field_bbox.corner.x) && - (start->y >= field_bbox.orig.y) && (start->y < field_bbox.corner.y)) { + (start->y >= field_bbox.orig.y) && (start->y < field_bbox.corner.y)) { end->x = start->x; end->y = start->y; } @@ -753,46 +753,46 @@ LeaderToLabel(ZnFieldSet field_set, if (delta.x) { if ((yu >= field_bbox.orig.y) && (yu <= field_bbox.corner.y) && - (field_bbox.orig.x >= inf.x) && (field_bbox.orig.x <= sup.x) && - (yu >= inf.y) && (yu <= sup.y)) { - end->x = field_bbox.orig.x; - end->y = yu; - inf.x = MIN(start->x, end->x); - sup.x = MAX(start->x, end->x); - inf.y = MIN(start->y, end->y); - sup.y = MAX(start->y, end->y); + (field_bbox.orig.x >= inf.x) && (field_bbox.orig.x <= sup.x) && + (yu >= inf.y) && (yu <= sup.y)) { + end->x = field_bbox.orig.x; + end->y = yu; + inf.x = MIN(start->x, end->x); + sup.x = MAX(start->x, end->x); + inf.y = MIN(start->y, end->y); + sup.y = MAX(start->y, end->y); } if ((yw >= field_bbox.orig.y) && (yw <= field_bbox.corner.y) && - (field_bbox.corner.x >= inf.x) && (field_bbox.corner.x <= sup.x) && - (yw >= inf.y) && (yw <= sup.y)) { - end->x = field_bbox.corner.x; - end->y = yw; - inf.x = MIN(start->x, end->x); - sup.x = MAX(start->x, end->x); - inf.y = MIN(start->y, end->y); - sup.y = MAX(start->y, end->y); + (field_bbox.corner.x >= inf.x) && (field_bbox.corner.x <= sup.x) && + (yw >= inf.y) && (yw <= sup.y)) { + end->x = field_bbox.corner.x; + end->y = yw; + inf.x = MIN(start->x, end->x); + sup.x = MAX(start->x, end->x); + inf.y = MIN(start->y, end->y); + sup.y = MAX(start->y, end->y); } } if (delta.y) { if ((xt >= field_bbox.orig.x) && (xt <= field_bbox.corner.x) && - (xt >= inf.x) && (xt <= sup.x) && - (field_bbox.corner.y >= inf.y) && (field_bbox.corner.y <= sup.y)) { - end->x = xt; - end->y = field_bbox.corner.y; - inf.x = MIN(start->x, end->x); - sup.x = MAX(start->x, end->x); - inf.y = MIN(start->y, end->y); - sup.y = MAX(start->y, end->y); + (xt >= inf.x) && (xt <= sup.x) && + (field_bbox.corner.y >= inf.y) && (field_bbox.corner.y <= sup.y)) { + end->x = xt; + end->y = field_bbox.corner.y; + inf.x = MIN(start->x, end->x); + sup.x = MAX(start->x, end->x); + inf.y = MIN(start->y, end->y); + sup.y = MAX(start->y, end->y); } if ((xv >= field_bbox.orig.x) && (xv <= field_bbox.corner.x) && - (xv >= inf.x) && (xv <= sup.x) && - (field_bbox.orig.y >= inf.y) && (field_bbox.orig.y <= sup.y)) { - end->x = xv; - end->y = field_bbox.orig.y; - inf.x = MIN(start->x, end->x); - sup.x = MAX(start->x, end->x); - inf.y = MIN(start->y, end->y); - sup.y = MAX(start->y, end->y); + (xv >= inf.x) && (xv <= sup.x) && + (field_bbox.orig.y >= inf.y) && (field_bbox.orig.y <= sup.y)) { + end->x = xv; + end->y = field_bbox.orig.y; + inf.x = MIN(start->x, end->x); + sup.x = MAX(start->x, end->x); + inf.y = MIN(start->y, end->y); + sup.y = MAX(start->y, end->y); } } } @@ -804,17 +804,17 @@ LeaderToLabel(ZnFieldSet field_set, * * InitFields -- * - * Perform the init of each field in a ZnFieldSet. The number of such - * fields must have been inited before calling this fun. + * Perform the init of each field in a ZnFieldSet. The number of such + * fields must have been inited before calling this fun. * ********************************************************************************** */ static void -InitFields(ZnFieldSet field_set) +InitFields(ZnFieldSet field_set) { - ZnWInfo *wi = field_set->item->wi; - Field field; - unsigned int i, num_fields; + ZnWInfo *wi = field_set->item->wi; + Field field; + unsigned int i, num_fields; /*printf("size of a field = %d\n", sizeof(FieldStruct));*/ @@ -865,12 +865,12 @@ InitFields(ZnFieldSet field_set) ********************************************************************************** */ static void -CloneFields(ZnFieldSet field_set) +CloneFields(ZnFieldSet field_set) { - ZnWInfo *wi = field_set->item->wi; - Field field, fields_ret; - unsigned int i, num_fields; - char *text; + ZnWInfo *wi = field_set->item->wi; + Field field, fields_ret; + unsigned int i, num_fields; + char *text; num_fields = field_set->num_fields; if (!num_fields) { @@ -924,21 +924,21 @@ CloneFields(ZnFieldSet field_set) ********************************************************************************** */ static int -ConfigureField(ZnFieldSet fs, - int field, - int argc, - Tcl_Obj *CONST argv[], - int *flags) +ConfigureField(ZnFieldSet fs, + int field, + int argc, + Tcl_Obj *CONST argv[], + int *flags) { - unsigned int i; - Field fptr; - ZnBBox bbox; - ZnWInfo *wi = fs->item->wi; - XColor *color; + unsigned int i; + Field fptr; + ZnBBox bbox; + ZnWInfo *wi = fs->item->wi; + XColor *color; unsigned short alpha; - int old_num_chars, num_chars; + int old_num_chars, num_chars; #ifdef GL - Tk_Font old_font; + Tk_Font old_font; #endif if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { @@ -956,7 +956,7 @@ ConfigureField(ZnFieldSet fs, } if (ZnConfigureAttributes(wi, fs->item, fptr, field_attrs, - argc, argv, flags) == TCL_ERROR) { + argc, argv, flags) == TCL_ERROR) { return TCL_ERROR; } @@ -972,15 +972,15 @@ ConfigureField(ZnFieldSet fs, */ if ((fs->item == ti->sel_item) && (field == ti->sel_field)) { if (ti->sel_last > num_chars) { - ti->sel_last = num_chars; + ti->sel_last = num_chars; } if (ti->sel_first >= ti->sel_last) { - ti->sel_item = ZN_NO_ITEM; - ti->sel_field = ZN_NO_PART; + ti->sel_item = ZN_NO_ITEM; + ti->sel_field = ZN_NO_PART; } if ((ti->anchor_item == fs->item) && (ti->anchor_field == field) && - (ti->sel_anchor > num_chars)) { - ti->sel_anchor = num_chars; + (ti->sel_anchor > num_chars)) { + ti->sel_anchor = num_chars; } } if (fptr->insert_index > num_chars) { @@ -1012,7 +1012,7 @@ ConfigureField(ZnFieldSet fs, if ((fptr->relief != ZN_RELIEF_FLAT) && !fptr->gradient) { color = ZnGetGradientColor(fptr->border_color, 51.0, &alpha); fptr->gradient = ZnGetReliefGradient(wi->interp, wi->win, - Tk_NameOfColor(color), alpha); + Tk_NameOfColor(color), alpha); if (fptr->gradient == NULL) { return TCL_ERROR; } @@ -1026,9 +1026,9 @@ ConfigureField(ZnFieldSet fs, fs->label_format && ISSET(*flags, ZN_DRAW_FLAG)) { for (i = 0; i < ZnLFNumFields(fs->label_format); i++) { if (i == (unsigned int) field) { - GetFieldBBox(fs, i, &bbox); - ZnDamage(wi, &bbox); - break; + GetFieldBBox(fs, i, &bbox); + ZnDamage(wi, &bbox); + break; } } } @@ -1045,10 +1045,10 @@ ConfigureField(ZnFieldSet fs, ********************************************************************************** */ static int -QueryField(ZnFieldSet fs, - int field, - int argc, - Tcl_Obj *CONST argv[]) +QueryField(ZnFieldSet fs, + int field, + int argc, + Tcl_Obj *CONST argv[]) { if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { Tcl_AppendResult(fs->item->wi->interp, "invalid field index \"", NULL); @@ -1056,7 +1056,7 @@ QueryField(ZnFieldSet fs, } if (ZnQueryAttribute(fs->item->wi->interp, &fs->fields[field], field_attrs, - argv[0]) == TCL_ERROR) { + argv[0]) == TCL_ERROR) { return TCL_ERROR; } @@ -1072,10 +1072,10 @@ QueryField(ZnFieldSet fs, ********************************************************************************** */ static void -FreeFields(ZnFieldSet field_set) +FreeFields(ZnFieldSet field_set) { - unsigned int i, num_fields; - Field field; + unsigned int i, num_fields; + Field field; if (field_set->label_format) { ZnLFDelete(field_set->label_format); @@ -1126,22 +1126,22 @@ FreeFields(ZnFieldSet field_set) * FieldDeleteChars, * FieldCursor, * FieldSelection -- - * These functions implement text edition in fields. The behavior + * These functions implement text edition in fields. The behavior * is the same as for Text items. * ********************************************************************************** */ static int -FieldPointToChar(ZnFieldSet fs, - unsigned int field, - int x, - int y) +FieldPointToChar(ZnFieldSet fs, + unsigned int field, + int x, + int y) { - Field fptr; - int byte_index; - ZnBBox f_bbox, t_bbox; - ZnPoint t_orig; - unsigned int num_bytes, n, dummy; + Field fptr; + int byte_index; + ZnBBox f_bbox, t_bbox; + ZnPoint t_orig; + unsigned int num_bytes, n, dummy; fptr = &fs->fields[field]; num_bytes = 0; @@ -1181,7 +1181,7 @@ FieldPointToChar(ZnFieldSet fs, goto convrt; } n = Tk_MeasureChars(fptr->font, fptr->text, num_bytes, - x + 2 - (int) t_bbox.orig.x, TK_PARTIAL_OK, &dummy); + x + 2 - (int) t_bbox.orig.x, TK_PARTIAL_OK, &dummy); byte_index = n - 1; goto convrt; } @@ -1195,9 +1195,9 @@ FieldPointToChar(ZnFieldSet fs, } static int -WordMoveFromIndex(char *text, - int index, - int fwd) +WordMoveFromIndex(char *text, + int index, + int fwd) { char const *strp; @@ -1227,18 +1227,18 @@ WordMoveFromIndex(char *text, } static int -FieldIndex(ZnFieldSet fs, - int field, - Tcl_Obj *index_spec, - int *index) +FieldIndex(ZnFieldSet fs, + int field, + Tcl_Obj *index_spec, + int *index) { - Field fptr; - ZnWInfo *wi = fs->item->wi; - ZnTextInfo *ti = &wi->text_info; - unsigned int length; - int c, x, y; - double tmp; - char *end, *p; + Field fptr; + ZnWInfo *wi = fs->item->wi; + ZnTextInfo *ti = &wi->text_info; + unsigned int length; + int c, x, y; + double tmp; + char *end, *p; if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { *index = 0; @@ -1276,7 +1276,7 @@ FieldIndex(ZnFieldSet fs, *index = fptr->insert_index; } else if ((c == 's') && (strncmp(p, "sel.first", length) == 0) && - (length >= 5)) { + (length >= 5)) { if ((ti->sel_item != fs->item) || (ti->sel_field != field)) { sel_err: Tcl_AppendResult(wi->interp, "selection isn't in field", (char *) NULL); @@ -1285,7 +1285,7 @@ FieldIndex(ZnFieldSet fs, *index = ti->sel_first; } else if ((c == 's') && (strncmp(p, "sel.last", length) == 0) && - (length >= 5)) { + (length >= 5)) { if ((ti->sel_item != fs->item) || (ti->sel_field != field)) { goto sel_err; } @@ -1313,7 +1313,7 @@ FieldIndex(ZnFieldSet fs, *index = FieldPointToChar(fs, (unsigned int) field, x, y); } else if (Tcl_GetIntFromObj(wi->interp, index_spec, index) == TCL_OK) { - int num_chars = fptr->text ? Tcl_NumUtfChars(fptr->text, (int) strlen(fptr->text)) : 0; + int num_chars = fptr->text ? Tcl_NumUtfChars(fptr->text, (int) strlen(fptr->text)) : 0; if (*index < 0){ *index = 0; } @@ -1331,16 +1331,16 @@ FieldIndex(ZnFieldSet fs, } static ZnBool -FieldInsertChars(ZnFieldSet fs, - int field, - int *index, - char *chars) +FieldInsertChars(ZnFieldSet fs, + int field, + int *index, + char *chars) { - Field fptr; - ZnTextInfo *ti = &fs->item->wi->text_info; - int num_chars, num_bytes, chars_added; - unsigned int byte_index, bytes_added = strlen(chars); - char *new; + Field fptr; + ZnTextInfo *ti = &fs->item->wi->text_info; + int num_chars, num_bytes, chars_added; + unsigned int byte_index, bytes_added = strlen(chars); + char *new; if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { return False; @@ -1393,7 +1393,7 @@ FieldInsertChars(ZnFieldSet fs, ti->sel_last += chars_added; } if ((ti->anchor_item == fs->item) && (ti->anchor_field == field) && - (ti->sel_anchor >= *index)) { + (ti->sel_anchor >= *index)) { ti->sel_anchor += chars_added; } } @@ -1406,16 +1406,16 @@ FieldInsertChars(ZnFieldSet fs, } static ZnBool -FieldDeleteChars(ZnFieldSet fs, - int field, - int *first, - int *last) +FieldDeleteChars(ZnFieldSet fs, + int field, + int *first, + int *last) { - Field fptr; - ZnTextInfo *ti = &fs->item->wi->text_info; - unsigned int char_count, byte_count; - unsigned int num_bytes, num_chars, first_offset; - char *new; + Field fptr; + ZnTextInfo *ti = &fs->item->wi->text_info; + unsigned int char_count, byte_count; + unsigned int num_bytes, num_chars, first_offset; + char *new; if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { return False; @@ -1471,23 +1471,23 @@ FieldDeleteChars(ZnFieldSet fs, if (ti->sel_first > *first) { ti->sel_first -= char_count; if (ti->sel_first < *first) { - ti->sel_first = *first; + ti->sel_first = *first; } } if (ti->sel_last >= *first) { ti->sel_last -= char_count; if (ti->sel_last < *first - 1) { - ti->sel_last = *first - 1; + ti->sel_last = *first - 1; } } if (ti->sel_first > ti->sel_last) { ti->sel_item = ZN_NO_ITEM; } if ((ti->anchor_item == fs->item) && (ti->anchor_field == field) && - (ti->sel_anchor > *first)) { + (ti->sel_anchor > *first)) { ti->sel_anchor -= char_count; if (ti->sel_anchor < *first) { - ti->sel_anchor = *first; + ti->sel_anchor = *first; } } } @@ -1500,12 +1500,12 @@ FieldDeleteChars(ZnFieldSet fs, } static void -FieldCursor(ZnFieldSet fs, - int field, - int index) +FieldCursor(ZnFieldSet fs, + int field, + int index) { - Field fptr; - int num_chars; + Field fptr; + int num_chars; if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { return; @@ -1529,15 +1529,15 @@ FieldCursor(ZnFieldSet fs, } static int -FieldSelection(ZnFieldSet fs, - int field, - int offset, - char *chars, - int max_bytes) +FieldSelection(ZnFieldSet fs, + int field, + int offset, + char *chars, + int max_bytes) { - Field fptr; - int count; - char const *sel_first, *sel_last; + Field fptr; + int count; + char const *sel_first, *sel_last; ZnTextInfo *ti; if ((field < 0) || ((unsigned int) field >= fs->num_fields)) { @@ -1575,17 +1575,17 @@ FieldSelection(ZnFieldSet fs, ********************************************************************************** * * ComputeFieldImageLocation -- - * Compute the bounding box of the pixmap in a field. The position is - * deduced from the field bounding box passed in bbox. + * Compute the bounding box of the pixmap in a field. The position is + * deduced from the field bounding box passed in bbox. * ********************************************************************************** */ static void -ComputeFieldImageLocation(Field fptr, - ZnBBox *bbox, - ZnBBox *pm_bbox) +ComputeFieldImageLocation(Field fptr, + ZnBBox *bbox, + ZnBBox *pm_bbox) { - int width, height; + int width, height; ZnSizeOfImage(fptr->image, &width, &height); pm_bbox->orig.y = (bbox->orig.y + bbox->corner.y - height) / 2; @@ -1614,24 +1614,24 @@ ComputeFieldImageLocation(Field fptr, ********************************************************************************** */ static void -FieldsEngine(ZnFieldSet field_set, - void (*cb)()) +FieldsEngine(ZnFieldSet field_set, + void (*cb)()) { - ZnWInfo *wi = field_set->item->wi; - /*int i; This one *NEED* to be an int */ - unsigned int i, num_fields, num_chars; - Field fptr; - ZnTextInfo *ti = &wi->text_info; - ZnBBox lclip_bbox, fclip_bbox, bbox, *global_clip_box; - ZnBBox tmp_bbox, text_bbox, pm_bbox; - ZnPoint pts[2]; - ZnTriStrip tristrip; - ZnPoint text_pos; - ZnBool restore = False; - ZnDim lwidth, lheight; - ZnReal val; - int cursor; - int sel_start, sel_stop; + ZnWInfo *wi = field_set->item->wi; + /*int i; This one *NEED* to be an int */ + unsigned int i, num_fields, num_chars; + Field fptr; + ZnTextInfo *ti = &wi->text_info; + ZnBBox lclip_bbox, fclip_bbox, bbox, *global_clip_box; + ZnBBox tmp_bbox, text_bbox, pm_bbox; + ZnPoint pts[2]; + ZnTriStrip tristrip; + ZnPoint text_pos; + ZnBool restore = False; + ZnDim lwidth, lheight; + ZnReal val; + int cursor; + int sel_start, sel_stop; if (!field_set->num_fields) { return; @@ -1648,7 +1648,7 @@ FieldsEngine(ZnFieldSet field_set, if (!wi->render) { ZnIntersectBBox(global_clip_box, &bbox, &lclip_bbox); if (ZnIsEmptyBBox(&lclip_bbox)) { - return; + return; } } else { @@ -1660,16 +1660,16 @@ FieldsEngine(ZnFieldSet field_set, fptr = &field_set->fields[i]; if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT)) { - continue; + continue; } GetFieldBBox(field_set, i, &bbox); ZnIntersectBBox(&lclip_bbox, &bbox, &fclip_bbox); if (ZnIsEmptyBBox(&fclip_bbox)) { - continue; + continue; } - /* we must call XSetClipRectangles only if it's required */ + /* we must call XSetClipRectangles only if it's required */ val = fclip_bbox.orig.x - bbox.orig.x; restore = val > 0; val = fclip_bbox.orig.y - bbox.orig.y; @@ -1680,74 +1680,74 @@ FieldsEngine(ZnFieldSet field_set, restore |= val < 0; cursor = ((field_set->item == wi->focus_item) && - ((unsigned int) wi->focus_field == i) && - ISSET(wi->flags, ZN_GOT_FOCUS) && ti->cursor_on) ? 0 : -1; + ((unsigned int) wi->focus_field == i) && + ISSET(wi->flags, ZN_GOT_FOCUS) && ti->cursor_on) ? 0 : -1; sel_start = -1, sel_stop = -1; ComputeFieldTextLocation(fptr, &bbox, &text_pos, &text_bbox); if (fptr->text) { - if (cursor != -1) { - cursor = Tk_TextWidth(fptr->font, fptr->text, - Tcl_UtfAtIndex(fptr->text, - fptr->insert_index)-fptr->text); - } - num_chars = Tcl_NumUtfChars(fptr->text, (int) strlen(fptr->text)); - if (num_chars) { - if ((field_set->item == ti->sel_item) && ((unsigned int) ti->sel_field == i) && - (ti->sel_last >= 0) && (ti->sel_first <= (int) num_chars)) { - sel_start = Tk_TextWidth(fptr->font, fptr->text, - Tcl_UtfAtIndex(fptr->text, - ti->sel_first)-fptr->text); - sel_stop = Tk_TextWidth(fptr->font, fptr->text, - Tcl_UtfAtIndex(fptr->text, - ti->sel_last)-fptr->text); - } - - ZnIntersectBBox(&fclip_bbox, &text_bbox, &tmp_bbox); - - val = tmp_bbox.orig.x - text_bbox.orig.x; - restore |= val > 0; - val = tmp_bbox.orig.y - text_bbox.orig.y; - restore |= val > 0; - val = tmp_bbox.corner.x - text_bbox.corner.x; - restore |= val < 0; - val = tmp_bbox.corner.y - text_bbox.corner.y; - restore |= val < 0; - } + if (cursor != -1) { + cursor = Tk_TextWidth(fptr->font, fptr->text, + Tcl_UtfAtIndex(fptr->text, + fptr->insert_index)-fptr->text); + } + num_chars = Tcl_NumUtfChars(fptr->text, (int) strlen(fptr->text)); + if (num_chars) { + if ((field_set->item == ti->sel_item) && ((unsigned int) ti->sel_field == i) && + (ti->sel_last >= 0) && (ti->sel_first <= (int) num_chars)) { + sel_start = Tk_TextWidth(fptr->font, fptr->text, + Tcl_UtfAtIndex(fptr->text, + ti->sel_first)-fptr->text); + sel_stop = Tk_TextWidth(fptr->font, fptr->text, + Tcl_UtfAtIndex(fptr->text, + ti->sel_last)-fptr->text); + } + + ZnIntersectBBox(&fclip_bbox, &text_bbox, &tmp_bbox); + + val = tmp_bbox.orig.x - text_bbox.orig.x; + restore |= val > 0; + val = tmp_bbox.orig.y - text_bbox.orig.y; + restore |= val > 0; + val = tmp_bbox.corner.x - text_bbox.corner.x; + restore |= val < 0; + val = tmp_bbox.corner.y - text_bbox.corner.y; + restore |= val < 0; + } } if (fptr->image != ZnUnspecifiedImage) { - ComputeFieldImageLocation(fptr, &bbox, &pm_bbox); - - ZnIntersectBBox(&fclip_bbox, &pm_bbox, &tmp_bbox); - - val = tmp_bbox.orig.x - pm_bbox.orig.x; - restore |= val > 0; - val = tmp_bbox.orig.y - pm_bbox.orig.y; - restore |= val > 0; - val = tmp_bbox.corner.x - pm_bbox.corner.x; - restore |= val < 0; - val = tmp_bbox.corner.y - pm_bbox.corner.y; - restore |= val < 0; + ComputeFieldImageLocation(fptr, &bbox, &pm_bbox); + + ZnIntersectBBox(&fclip_bbox, &pm_bbox, &tmp_bbox); + + val = tmp_bbox.orig.x - pm_bbox.orig.x; + restore |= val > 0; + val = tmp_bbox.orig.y - pm_bbox.orig.y; + restore |= val > 0; + val = tmp_bbox.corner.x - pm_bbox.corner.x; + restore |= val < 0; + val = tmp_bbox.corner.y - pm_bbox.corner.y; + restore |= val < 0; } /*restore = True;*/ if (restore) { - /* we must clip. */ - /*printf("clip: %d\n", i);*/ - pts[0] = fclip_bbox.orig; - pts[1] = fclip_bbox.corner; - ZnTriStrip1(&tristrip, pts, 2, False); - ZnPushClip(wi, &tristrip, True, True); + /* we must clip. */ + /*printf("clip: %d\n", i);*/ + pts[0] = fclip_bbox.orig; + pts[1] = fclip_bbox.corner; + ZnTriStrip1(&tristrip, pts, 2, False); + ZnPushClip(wi, &tristrip, True, True); } (*cb)(wi, fptr, &bbox, &pm_bbox, - &text_pos, &text_bbox, cursor, sel_start, sel_stop); + &text_pos, &text_bbox, cursor, sel_start, sel_stop); if (restore) { - /* Restore the previous clip. */ - ZnPopClip(wi, True); - restore = False; + /* Restore the previous clip. */ + ZnPopClip(wi, True); + restore = False; } } } @@ -1762,25 +1762,25 @@ FieldsEngine(ZnFieldSet field_set, ********************************************************************************** */ static void -DrawField(ZnWInfo *wi, - Field fptr, - ZnBBox *bbox, - ZnBBox *pm_bbox, - ZnPoint *text_pos, - ZnBBox *text_bbox, - int cursor, - int sel_start, - int sel_stop) +DrawField(ZnWInfo *wi, + Field fptr, + ZnBBox *bbox, + ZnBBox *pm_bbox, + ZnPoint *text_pos, + ZnBBox *text_bbox, + int cursor, + int sel_start, + int sel_stop) { - ZnTextInfo *ti = &wi->text_info; - XGCValues values; - XRectangle r; - int j, xs, num_bytes; - int pw, ph, fw, fh; - TkRegion clip_region; - ZnBool simple; - Pixmap pixmap; - TkRegion photo_region, clip; + ZnTextInfo *ti = &wi->text_info; + XGCValues values; + XRectangle r; + int j, xs, num_bytes; + int pw, ph, fw, fh; + TkRegion clip_region; + ZnBool simple; + Pixmap pixmap; + TkRegion photo_region, clip; ZnBBox2XRect(bbox, &r); @@ -1792,22 +1792,22 @@ DrawField(ZnWInfo *wi, if (fptr->tile != ZnUnspecifiedImage) { if (!ZnImageIsBitmap(fptr->tile)) { /* Fill tiled */ - values.fill_style = FillTiled; - values.tile = ZnImagePixmap(fptr->tile, wi->win); - values.ts_x_origin = (int) bbox->orig.x; - values.ts_y_origin = (int) bbox->orig.y; - XChangeGC(wi->dpy, wi->gc, - GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile, - &values); + values.fill_style = FillTiled; + values.tile = ZnImagePixmap(fptr->tile, wi->win); + values.ts_x_origin = (int) bbox->orig.x; + values.ts_y_origin = (int) bbox->orig.y; + XChangeGC(wi->dpy, wi->gc, + GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCTile, + &values); } else { /* Fill stippled */ - values.fill_style = FillStippled; - values.stipple = ZnImagePixmap(fptr->tile, wi->win); - values.ts_x_origin = (int) bbox->orig.x; - values.ts_y_origin = (int) bbox->orig.y; - XChangeGC(wi->dpy, wi->gc, - GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground, - &values); + values.fill_style = FillStippled; + values.stipple = ZnImagePixmap(fptr->tile, wi->win); + values.ts_x_origin = (int) bbox->orig.x; + values.ts_y_origin = (int) bbox->orig.y; + XChangeGC(wi->dpy, wi->gc, + GCTileStipXOrigin|GCTileStipYOrigin|GCFillStyle|GCStipple|GCForeground, + &values); } } else { /* Fill solid */ @@ -1823,49 +1823,49 @@ DrawField(ZnWInfo *wi, */ for (j = 0; j < 2; j++) { if ((j == 0 && ISSET(fptr->flags, TEXT_ON_TOP_BIT)) || - (j == 1 && ISCLEAR(fptr->flags, TEXT_ON_TOP_BIT))) { + (j == 1 && ISCLEAR(fptr->flags, TEXT_ON_TOP_BIT))) { /* * Draw the image. */ if (fptr->image != ZnUnspecifiedImage) { - pw = ZnNearestInt(pm_bbox->corner.x - pm_bbox->orig.x); - ph = ZnNearestInt(pm_bbox->corner.y - pm_bbox->orig.y); - fw = ZnNearestInt(bbox->corner.x - bbox->orig.x); - fh = ZnNearestInt(bbox->corner.y - bbox->orig.y); - - pixmap = ZnImagePixmap(fptr->image, wi->win); - photo_region = ZnImageRegion(fptr->image); - ZnCurrentClip(wi, &clip_region, NULL, &simple); - clip = TkCreateRegion(); - /* - * ZnImageRegion may fail: perl/Tk 800.24 doesn't support - * some internal TkPhoto functions. - * This is a workaround using a rectangular region based - * on the image size. - */ - if (photo_region == NULL) { - XRectangle rect; - rect.x = rect.y = 0; - rect.width = pw; - rect.height = ph; - TkUnionRectWithRegion(&rect, clip, clip); - } - else { - ZnUnionRegion(clip, photo_region, clip); - } - ZnOffsetRegion(clip, (int) pm_bbox->orig.x, (int) pm_bbox->orig.y); - TkIntersectRegion(clip_region, clip, clip); - TkSetRegion(wi->dpy, wi->gc, clip); - XCopyArea(wi->dpy, pixmap, wi->draw_buffer, wi->gc, - (int) ZnNearestInt(bbox->orig.x-pm_bbox->orig.x), - (int) ZnNearestInt(bbox->orig.y-pm_bbox->orig.y), - (unsigned int) MIN(pw, fw), - (unsigned int) MIN(ph, fh), - (int) MAX(bbox->orig.x, pm_bbox->orig.x), - (int) MAX(bbox->orig.y, pm_bbox->orig.y)); - - TkSetRegion(wi->dpy, wi->gc, clip_region); - TkDestroyRegion(clip); + pw = ZnNearestInt(pm_bbox->corner.x - pm_bbox->orig.x); + ph = ZnNearestInt(pm_bbox->corner.y - pm_bbox->orig.y); + fw = ZnNearestInt(bbox->corner.x - bbox->orig.x); + fh = ZnNearestInt(bbox->corner.y - bbox->orig.y); + + pixmap = ZnImagePixmap(fptr->image, wi->win); + photo_region = ZnImageRegion(fptr->image); + ZnCurrentClip(wi, &clip_region, NULL, &simple); + clip = TkCreateRegion(); + /* + * ZnImageRegion may fail: perl/Tk 800.24 doesn't support + * some internal TkPhoto functions. + * This is a workaround using a rectangular region based + * on the image size. + */ + if (photo_region == NULL) { + XRectangle rect; + rect.x = rect.y = 0; + rect.width = pw; + rect.height = ph; + TkUnionRectWithRegion(&rect, clip, clip); + } + else { + ZnUnionRegion(clip, photo_region, clip); + } + ZnOffsetRegion(clip, (int) pm_bbox->orig.x, (int) pm_bbox->orig.y); + TkIntersectRegion(clip_region, clip, clip); + TkSetRegion(wi->dpy, wi->gc, clip); + XCopyArea(wi->dpy, pixmap, wi->draw_buffer, wi->gc, + (int) ZnNearestInt(bbox->orig.x-pm_bbox->orig.x), + (int) ZnNearestInt(bbox->orig.y-pm_bbox->orig.y), + (unsigned int) MIN(pw, fw), + (unsigned int) MIN(ph, fh), + (int) MAX(bbox->orig.x, pm_bbox->orig.x), + (int) MAX(bbox->orig.y, pm_bbox->orig.y)); + + TkSetRegion(wi->dpy, wi->gc, clip_region); + TkDestroyRegion(clip); } } else if (fptr->text) { @@ -1874,22 +1874,22 @@ DrawField(ZnWInfo *wi, */ num_bytes = strlen(fptr->text); if (num_bytes) { - if (sel_start >= 0) { - values.foreground = ZnGetGradientPixel(ti->sel_color, 0.0); - values.fill_style = FillSolid; - XChangeGC(wi->dpy, wi->gc, GCForeground|GCFillStyle, &values); - XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, - (int) (text_bbox->orig.x+sel_start), - (int) text_bbox->orig.y, - (unsigned int) (sel_stop-sel_start), - (unsigned int) (text_bbox->corner.y-text_bbox->orig.y)); - } - values.foreground = ZnGetGradientPixel(fptr->color, 0.0); - values.fill_style = FillSolid; - values.font = Tk_FontId(fptr->font); - XChangeGC(wi->dpy, wi->gc, GCForeground | GCFillStyle | GCFont, &values); - Tk_DrawChars(wi->dpy, wi->draw_buffer, wi->gc, fptr->font, - fptr->text, num_bytes, (int) text_pos->x, (int) text_pos->y); + if (sel_start >= 0) { + values.foreground = ZnGetGradientPixel(ti->sel_color, 0.0); + values.fill_style = FillSolid; + XChangeGC(wi->dpy, wi->gc, GCForeground|GCFillStyle, &values); + XFillRectangle(wi->dpy, wi->draw_buffer, wi->gc, + (int) (text_bbox->orig.x+sel_start), + (int) text_bbox->orig.y, + (unsigned int) (sel_stop-sel_start), + (unsigned int) (text_bbox->corner.y-text_bbox->orig.y)); + } + values.foreground = ZnGetGradientPixel(fptr->color, 0.0); + values.fill_style = FillSolid; + values.font = Tk_FontId(fptr->font); + XChangeGC(wi->dpy, wi->gc, GCForeground | GCFillStyle | GCFont, &values); + Tk_DrawChars(wi->dpy, wi->draw_buffer, wi->gc, fptr->font, + fptr->text, num_bytes, (int) text_pos->x, (int) text_pos->y); } } } @@ -1900,8 +1900,8 @@ DrawField(ZnWInfo *wi, XChangeGC(wi->dpy, wi->gc, GCForeground|GCLineWidth|GCFillStyle, &values); xs = (int) text_bbox->orig.x + cursor; XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - xs, (int) text_bbox->orig.y, - xs, (int) text_bbox->corner.y); + xs, (int) text_bbox->orig.y, + xs, (int) text_bbox->corner.y); } /* @@ -1909,7 +1909,7 @@ DrawField(ZnWInfo *wi, */ if ((fptr->relief != ZN_RELIEF_FLAT) && (fptr->relief_thickness > 1)) { ZnDrawRectangleRelief(wi, fptr->relief, fptr->gradient, - &r, fptr->relief_thickness); + &r, fptr->relief_thickness); } /* @@ -1921,39 +1921,39 @@ DrawField(ZnWInfo *wi, values.line_style = LineSolid; values.fill_style = FillSolid; XChangeGC(wi->dpy, wi->gc, - GCForeground | GCLineWidth | GCLineStyle | GCFillStyle, &values); + GCForeground | GCLineWidth | GCLineStyle | GCFillStyle, &values); if (fptr->border_edges & ZN_LEFT_BORDER) { XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y, - r.x, r.y + r.height - 1); + r.x, r.y + r.height - 1); } if (fptr->border_edges & ZN_RIGHT_BORDER) { XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - r.x + r.width - 1, r.y, - r.x + r.width - 1, r.y + r.height - 1); + r.x + r.width - 1, r.y, + r.x + r.width - 1, r.y + r.height - 1); } if (fptr->border_edges & ZN_TOP_BORDER) { XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - r.x, r.y, r.x + r.width - 1, r.y); + r.x, r.y, r.x + r.width - 1, r.y); } if (fptr->border_edges & ZN_BOTTOM_BORDER) { XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - r.x, r.y + r.height - 1, - r.x + r.width - 1, r.y + r.height - 1); + r.x, r.y + r.height - 1, + r.x + r.width - 1, r.y + r.height - 1); } if (fptr->border_edges & ZN_OBLIQUE) { XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - r.x, r.y, r.x + r.width - 1, r.y + r.height - 1); + r.x, r.y, r.x + r.width - 1, r.y + r.height - 1); } if (fptr->border_edges & ZN_COUNTER_OBLIQUE) { XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - r.x, r.y + r.height - 1, - r.x + r.width - 1, r.y); + r.x, r.y + r.height - 1, + r.x + r.width - 1, r.y); } } } static void -DrawFields(ZnFieldSet field_set) +DrawFields(ZnFieldSet field_set) { FieldsEngine(field_set, DrawField); } @@ -1981,21 +1981,21 @@ FieldRenderCB(void *closure) } static void -RenderField(ZnWInfo *wi, - Field fptr, - ZnBBox *bbox, - ZnBBox *pm_bbox, - ZnPoint *text_pos, - ZnBBox *text_bbox, - int cursor, - int sel_start, - int sel_stop) +RenderField(ZnWInfo *wi, + Field fptr, + ZnBBox *bbox, + ZnBBox *pm_bbox, + ZnPoint *text_pos, + ZnBBox *text_bbox, + int cursor, + int sel_start, + int sel_stop) { unsigned short alpha; - unsigned int j, num_bytes; - XColor *color; - ZnReal xs; - ZnTextInfo *ti = &wi->text_info; + unsigned int j, num_bytes; + XColor *color; + ZnReal xs; + ZnTextInfo *ti = &wi->text_info; /* * Draw the background. @@ -2004,24 +2004,24 @@ RenderField(ZnWInfo *wi, glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (!ZnGradientFlat(fptr->fill_color)) { #if 0 /* TODO_GL Faire le dégradé dans le fond des champs. */ - int type = fptr->fill_color->type; - ZnBool fast = (type == ZN_AXIAL_GRADIENT) && !fptr->grad_geo; + int type = fptr->fill_color->type; + ZnBool fast = (type == ZN_AXIAL_GRADIENT) && !fptr->grad_geo; RenderGradient(wi, fptr->fill_color, - fast ? NULL : FieldRenderCB, - bbox, fast ? (ZnPoint *) bbox : fptr->grad_geo); + fast ? NULL : FieldRenderCB, + bbox, fast ? (ZnPoint *) bbox : fptr->grad_geo); #endif } else { if (fptr->tile != ZnUnspecifiedImage) { /* Fill tiled/stippled */ - ZnRenderTile(wi, fptr->tile, fptr->fill_color, FieldRenderCB, bbox, - (ZnPoint *) bbox); + ZnRenderTile(wi, fptr->tile, fptr->fill_color, FieldRenderCB, bbox, + (ZnPoint *) bbox); } else { /* Fill solid */ - color = ZnGetGradientColor(fptr->fill_color, 0.0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - FieldRenderCB(bbox); + color = ZnGetGradientColor(fptr->fill_color, 0.0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); + glColor4us(color->red, color->green, color->blue, alpha); + FieldRenderCB(bbox); } } } @@ -2032,13 +2032,13 @@ RenderField(ZnWInfo *wi, */ for (j = 0; j < 2; j++) { if ((j == 0 && ISSET(fptr->flags, TEXT_ON_TOP_BIT)) || - (j == 1 && ISCLEAR(fptr->flags, TEXT_ON_TOP_BIT))) { + (j == 1 && ISCLEAR(fptr->flags, TEXT_ON_TOP_BIT))) { /* * Draw the image. */ if (fptr->image != ZnUnspecifiedImage) { - ZnRenderIcon(wi, fptr->image, fptr->fill_color, - &pm_bbox->orig, False); + ZnRenderIcon(wi, fptr->image, fptr->fill_color, + &pm_bbox->orig, False); } } else if (fptr->text) { @@ -2047,29 +2047,29 @@ RenderField(ZnWInfo *wi, */ num_bytes = strlen(fptr->text); if (num_bytes) { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - if (sel_start >= 0) { - color = ZnGetGradientColor(ti->sel_color, 0.0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - glBegin(GL_QUADS); - glVertex2d(text_bbox->orig.x+sel_start, text_bbox->orig.y); - glVertex2d(text_bbox->orig.x+sel_stop, text_bbox->orig.y); - glVertex2d(text_bbox->orig.x+sel_stop, text_bbox->corner.y); - glVertex2d(text_bbox->orig.x+sel_start, text_bbox->corner.y); - glEnd(); - } - glEnable(GL_TEXTURE_2D); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - color = ZnGetGradientColor(fptr->color, 0.0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - glBindTexture(GL_TEXTURE_2D, ZnTexFontTex(fptr->tfi)); - glPushMatrix(); - glTranslated(text_pos->x, text_pos->y, 0.0); - ZnRenderString(fptr->tfi, fptr->text, num_bytes); - glPopMatrix(); - glDisable(GL_TEXTURE_2D); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + if (sel_start >= 0) { + color = ZnGetGradientColor(ti->sel_color, 0.0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); + glColor4us(color->red, color->green, color->blue, alpha); + glBegin(GL_QUADS); + glVertex2d(text_bbox->orig.x+sel_start, text_bbox->orig.y); + glVertex2d(text_bbox->orig.x+sel_stop, text_bbox->orig.y); + glVertex2d(text_bbox->orig.x+sel_stop, text_bbox->corner.y); + glVertex2d(text_bbox->orig.x+sel_start, text_bbox->corner.y); + glEnd(); + } + glEnable(GL_TEXTURE_2D); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + color = ZnGetGradientColor(fptr->color, 0.0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); + glColor4us(color->red, color->green, color->blue, alpha); + glBindTexture(GL_TEXTURE_2D, ZnTexFontTex(fptr->tfi)); + glPushMatrix(); + glTranslated(text_pos->x, text_pos->y, 0.0); + ZnRenderString(fptr->tfi, fptr->text, num_bytes); + glPopMatrix(); + glDisable(GL_TEXTURE_2D); } } if (cursor >= 0) { @@ -2101,7 +2101,7 @@ RenderField(ZnWInfo *wi, p[3].y = p[0].y; p[4] = p[0]; ZnRenderPolygonRelief(wi, fptr->relief, fptr->gradient, - False, p, 5, fptr->relief_thickness); + False, p, 5, fptr->relief_thickness); } /* @@ -2144,7 +2144,7 @@ RenderField(ZnWInfo *wi, #endif static void -RenderFields(ZnFieldSet field_set) +RenderFields(ZnFieldSet field_set) { #ifdef GL /* glDisable(GL_LINE_SMOOTH);*/ @@ -2162,8 +2162,8 @@ RenderFields(ZnFieldSet field_set) ********************************************************************************** */ static ZnBool -IsFieldSensitive(ZnFieldSet field_set, - int part) +IsFieldSensitive(ZnFieldSet field_set, + int part) { if ((part >= 0) && ((unsigned int) part < field_set->num_fields)) { return ISSET(field_set->fields[part].flags, FIELD_SENSITIVE_BIT); @@ -2178,26 +2178,26 @@ IsFieldSensitive(ZnFieldSet field_set, ********************************************************************************** * * FieldsPick -- - * Return the first field that contains <x, y>. - * A field is selected if <x, y> is over a non transparent area. - * Such areas are : a solid filled background, a text, an icon. - * This does *NOT* do with *GLOBAL* visible and sensitive. - * But we need to take into account local field visible and - * sensitive as they modifiy local transparency. Local means - * within a single item. + * Return the first field that contains <x, y>. + * A field is selected if <x, y> is over a non transparent area. + * Such areas are : a solid filled background, a text, an icon. + * This does *NOT* do with *GLOBAL* visible and sensitive. + * But we need to take into account local field visible and + * sensitive as they modifiy local transparency. Local means + * within a single item. * ********************************************************************************** */ static double -FieldsPick(ZnFieldSet field_set, - ZnPoint *p, - int *part) +FieldsPick(ZnFieldSet field_set, + ZnPoint *p, + int *part) { - Field fptr; - ZnBBox bbox; - unsigned int best_field = 0; - int i; - ZnReal new_dist, dist = 1e40; + Field fptr; + ZnBBox bbox; + unsigned int best_field = 0; + int i; + ZnReal new_dist, dist = 1e40; if (!field_set->num_fields) { return dist; @@ -2208,20 +2208,20 @@ FieldsPick(ZnFieldSet field_set, fptr = &field_set->fields[i]; if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT) && - ISCLEAR(fptr->flags, FIELD_SENSITIVE_BIT)) { - continue; + ISCLEAR(fptr->flags, FIELD_SENSITIVE_BIT)) { + continue; } GetFieldBBox(field_set, (unsigned int) i, &bbox); new_dist = ZnRectangleToPointDist(&bbox, p); if (new_dist < dist) { - dist = new_dist; - best_field = i; + dist = new_dist; + best_field = i; } if (dist <= 0.0) { - dist = 0.0; - break; + dist = 0.0; + break; } } } @@ -2235,20 +2235,20 @@ FieldsPick(ZnFieldSet field_set, ********************************************************************************** * * FieldsToArea -- - * Return -1 if no field is in the given area, 1 if they are - * all in it or 0 if there is some overlap. The function consider - * only fields that are either sensible or visible. + * Return -1 if no field is in the given area, 1 if they are + * all in it or 0 if there is some overlap. The function consider + * only fields that are either sensible or visible. * ********************************************************************************** */ static int -FieldsToArea(ZnFieldSet field_set, - ZnBBox *area) +FieldsToArea(ZnFieldSet field_set, + ZnBBox *area) { - Field fptr; - ZnBBox bbox; - int i, inside = -1; - ZnBool first_done = False; + Field fptr; + ZnBBox bbox; + int i, inside = -1; + ZnBool first_done = False; if (!field_set->num_fields) { return inside; @@ -2258,7 +2258,7 @@ FieldsToArea(ZnFieldSet field_set, fptr = &field_set->fields[i]; if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT) && - ISCLEAR(fptr->flags, FIELD_SENSITIVE_BIT)) { + ISCLEAR(fptr->flags, FIELD_SENSITIVE_BIT)) { continue; } @@ -2267,12 +2267,12 @@ FieldsToArea(ZnFieldSet field_set, first_done = True; inside = ZnBBoxInBBox(&bbox, area); if (inside == 0) { - return 0; + return 0; } } else { if (ZnBBoxInBBox(&bbox, area) != inside) { - return 0; + return 0; } } } @@ -2289,11 +2289,11 @@ FieldsToArea(ZnFieldSet field_set, ********************************************************************************** */ static void -SetFieldsAutoAlign(ZnFieldSet fs, - int alignment) +SetFieldsAutoAlign(ZnFieldSet fs, + int alignment) { - unsigned int i; - Field field; + unsigned int i; + Field field; if (!fs->num_fields) { return; @@ -2302,15 +2302,15 @@ SetFieldsAutoAlign(ZnFieldSet fs, for (i = 0; i < fs->num_fields; i++) { field = &fs->fields[i]; if (field->auto_alignment.automatic) { - field->alignment = field->auto_alignment.align[alignment]; + field->alignment = field->auto_alignment.align[alignment]; } } } } static char * -GetFieldStruct(ZnFieldSet fs, - int field) +GetFieldStruct(ZnFieldSet fs, + int field) { if ((unsigned int) field >= fs->num_fields) { return NULL; @@ -2320,7 +2320,7 @@ GetFieldStruct(ZnFieldSet fs, static unsigned int -NumFields(ZnFieldSet fs) +NumFields(ZnFieldSet fs) { return fs->num_fields; } |