aboutsummaryrefslogtreecommitdiff
path: root/generic/Field.c
diff options
context:
space:
mode:
authorlecoanet2002-12-20 13:47:27 +0000
committerlecoanet2002-12-20 13:47:27 +0000
commitb407243408030d04db48e48216b40dfab1070a2f (patch)
treefe949f787c7b88cd2cef8bc0becdd2c4252c163b /generic/Field.c
parent9a0507b3895e7ed1644048b0c3569bc36aa737e2 (diff)
downloadtkzinc-b407243408030d04db48e48216b40dfab1070a2f.zip
tkzinc-b407243408030d04db48e48216b40dfab1070a2f.tar.gz
tkzinc-b407243408030d04db48e48216b40dfab1070a2f.tar.bz2
tkzinc-b407243408030d04db48e48216b40dfab1070a2f.tar.xz
Passage en UTF8 pour la version Tcl
Diffstat (limited to 'generic/Field.c')
-rw-r--r--generic/Field.c577
1 files changed, 315 insertions, 262 deletions
diff --git a/generic/Field.c b/generic/Field.c
index 95b06e1..41e11e8 100644
--- a/generic/Field.c
+++ b/generic/Field.c
@@ -158,15 +158,15 @@ ComputeFieldAttachment(FieldSet field_set,
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 field_ptr;
+ Field fptr;
Tk_FontMetrics fm;
- field_ptr = &field_set->fields[field];
- if (ISSET(field_ptr->flags, CACHE_OK)) {
- field_bbox->orig.x = (ZnPos) field_ptr->orig_x;
- field_bbox->orig.y = (ZnPos) field_ptr->orig_y;
- field_bbox->corner.x = field_ptr->corner_x;
- field_bbox->corner.y = field_ptr->corner_y;
+ fptr = &field_set->fields[field];
+ if (ISSET(fptr->flags, CACHE_OK)) {
+ field_bbox->orig.x = (ZnPos) fptr->orig_x;
+ field_bbox->orig.y = (ZnPos) fptr->orig_y;
+ field_bbox->corner.x = fptr->corner_x;
+ field_bbox->corner.y = fptr->corner_y;
return;
}
@@ -174,11 +174,11 @@ ComputeFieldAttachment(FieldSet field_set,
* Preset this field to a default position/size and pretend
* its cache is ok to break any deadlocks.
*/
- field_ptr->orig_x = field_ptr->orig_y = 0;
- field_ptr->corner_x = field_ptr->corner_y = 0;
+ fptr->orig_x = fptr->orig_y = 0;
+ fptr->corner_x = fptr->corner_y = 0;
field_bbox->orig.x = field_bbox->orig.y = 0;
field_bbox->corner.x = field_bbox->corner.y = 0;
- SET(field_ptr->flags, CACHE_OK);
+ SET(fptr->flags, CACHE_OK);
num_fields = LabelFormatNumFields(field_set->label_format);
LabelFormatGetField(field_set->label_format, field,
@@ -189,15 +189,15 @@ ComputeFieldAttachment(FieldSet field_set,
* First try to compute the field size which may be a factor
* of the field content (but not a factor of other fields).
*/
- if ((field_ptr->image != ZnUnspecifiedImage) &&
+ if ((fptr->image != ZnUnspecifiedImage) &&
((x_dim == LF_DIM_ICON) || (y_dim == LF_DIM_ICON) ||
(x_dim == LF_DIM_AUTO) || (y_dim == LF_DIM_AUTO))) {
- ZnSizeOfImage(field_ptr->image, &icon_width, &icon_height);
+ ZnSizeOfImage(fptr->image, &icon_width, &icon_height);
}
switch (x_dim) {
case LF_DIM_FONT:
- real_width = (ZnDim) (width_spec*ZnTextWidth(field_ptr->font, "N", 1)/100);
+ real_width = (ZnDim) (width_spec*ZnTextWidth(fptr->font, "N", 1)/100);
break;
case LF_DIM_ICON:
real_width = (ZnDim) (width_spec*icon_width/100);
@@ -207,18 +207,18 @@ ComputeFieldAttachment(FieldSet field_set,
int len = 0;
ZnDim text_width;
- if (field_ptr->text) {
- len = strlen(field_ptr->text);
+ if (fptr->text) {
+ len = strlen(fptr->text);
}
real_width = 0.0;
- if (field_ptr->image != ZnUnspecifiedImage) {
+ if (fptr->image != ZnUnspecifiedImage) {
real_width = (ZnDim) icon_width;
}
if (len) {
/*
* The 4 extra pixels are needed for border and padding.
*/
- text_width = (ZnDim) ZnTextWidth(field_ptr->font, field_ptr->text, len) + 4;
+ text_width = (ZnDim) ZnTextWidth(fptr->font, fptr->text, len) + 4;
real_width = text_width < real_width ? real_width : text_width;
}
real_width += (ZnDim) width_spec;
@@ -241,7 +241,7 @@ ComputeFieldAttachment(FieldSet field_set,
switch (y_dim) {
case LF_DIM_FONT:
{
- Tk_GetFontMetrics(field_ptr->font, &fm);
+ Tk_GetFontMetrics(fptr->font, &fm);
real_height = (ZnDim) (height_spec*(fm.ascent + fm.descent)/100);
break;
}
@@ -253,11 +253,11 @@ ComputeFieldAttachment(FieldSet field_set,
ZnDim text_height;
real_height = 0.0;
- if (field_ptr->image != ZnUnspecifiedImage) {
+ if (fptr->image != ZnUnspecifiedImage) {
real_height = (ZnDim) icon_height;
}
- if (field_ptr->text && strlen(field_ptr->text)) {
- Tk_GetFontMetrics(field_ptr->font, &fm);
+ 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;
}
@@ -282,8 +282,8 @@ ComputeFieldAttachment(FieldSet field_set,
* Update the cache with the newly computed infos
* (breaking of deadlocks).
*/
- field_bbox->corner.x = field_ptr->corner_x = real_width;
- field_bbox->corner.y = field_ptr->corner_y = real_height;
+ field_bbox->corner.x = fptr->corner_x = real_width;
+ field_bbox->corner.y = fptr->corner_y = real_height;
/*
* Then try to deduce the position, resolving any attachments
@@ -398,11 +398,11 @@ ComputeFieldAttachment(FieldSet field_set,
/*printf("field %d, y = %g\n", field, field_bbox->orig.y);*/
}
- field_ptr->orig_x = (short) field_bbox->orig.x;
- field_ptr->orig_y = (short) field_bbox->orig.y;
- field_ptr->corner_x = (short) field_bbox->corner.x;
- field_ptr->corner_y = (short) field_bbox->corner.y;
- SET(field_ptr->flags, CACHE_OK);
+ fptr->orig_x = (short) field_bbox->orig.x;
+ fptr->orig_y = (short) field_bbox->orig.y;
+ fptr->corner_x = (short) field_bbox->corner.x;
+ fptr->corner_y = (short) field_bbox->corner.y;
+ SET(fptr->flags, CACHE_OK);
}
@@ -581,7 +581,7 @@ GetFieldBBox(FieldSet field_set,
**********************************************************************************
*/
static void
-ComputeFieldTextLocation(Field field_ptr,
+ComputeFieldTextLocation(Field fptr,
ZnBBox *bbox,
ZnPoint *pos,
ZnBBox *text_bbox)
@@ -589,17 +589,17 @@ ComputeFieldTextLocation(Field field_ptr,
ZnDim w, h;
Tk_FontMetrics fm;
- Tk_GetFontMetrics(field_ptr->font, &fm);
+ Tk_GetFontMetrics(fptr->font, &fm);
w = 0;
- if (field_ptr->text) {
- w = ZnTextWidth(field_ptr->font, field_ptr->text, strlen(field_ptr->text));
+ if (fptr->text) {
+ w = ZnTextWidth(fptr->font, fptr->text, strlen(fptr->text));
}
h = fm.ascent + fm.descent;
text_bbox->orig.y = (bbox->orig.y + bbox->corner.y - h) / 2.0;
text_bbox->corner.y = text_bbox->orig.y + h;
pos->y = text_bbox->orig.y + fm.ascent;
- switch (field_ptr->alignment) {
+ switch (fptr->alignment) {
case ZnJustifyLeft:
text_bbox->orig.x = bbox->orig.x + 2;
break;
@@ -632,7 +632,7 @@ LeaderToLabel(FieldSet field_set,
int b_num;
ZnPoint delta, inf, sup;
ZnPos xt=0, yu=0, yw=0, xv=0;
- Field field_ptr;
+ Field fptr;
int i;
ZnBBox field_bbox;
@@ -649,17 +649,17 @@ LeaderToLabel(FieldSet field_set,
b_num = start->y*delta.x - start->x*delta.y;
for (i = 0; i < LabelFormatNumFields(field_set->label_format); i++) {
- field_ptr = &field_set->fields[i];
+ fptr = &field_set->fields[i];
/*
* If the field is made invisible or has no graphics of
* its own, don't clip.
*/
- if (ISCLEAR(field_ptr->flags, FIELD_VISIBLE_BIT) ||
- (!field_ptr->text &&
- ISCLEAR(field_ptr->flags, FILLED_BIT) &&
- (field_ptr->border_edges == NO_BORDER) &&
- (field_ptr->relief == RELIEF_FLAT) &&
- (field_ptr->image == ZnUnspecifiedImage))) {
+ if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT) ||
+ (!fptr->text &&
+ ISCLEAR(fptr->flags, FILLED_BIT) &&
+ (fptr->border_edges == NO_BORDER) &&
+ (fptr->relief == RELIEF_FLAT) &&
+ (fptr->image == ZnUnspecifiedImage))) {
continue;
}
@@ -672,18 +672,18 @@ LeaderToLabel(FieldSet field_set,
* Adjust leader on real text, not on field boundaries. This is
* important when there are leading and trailing spaces.
*/
- if (field_ptr->text &&
- ISCLEAR(field_ptr->flags, FILLED_BIT) &&
- (field_ptr->border_edges == NO_BORDER) &&
- (field_ptr->relief == RELIEF_FLAT) &&
- (field_ptr->image == ZnUnspecifiedImage)) {
+ if (fptr->text &&
+ ISCLEAR(fptr->flags, FILLED_BIT) &&
+ (fptr->border_edges == NO_BORDER) &&
+ (fptr->relief == RELIEF_FLAT) &&
+ (fptr->image == ZnUnspecifiedImage)) {
ZnBBox text_bbox;
ZnPoint text_pos; /* dummy */
int space_width;
int scan_forw, scan_back;
- space_width = ZnTextWidth(field_ptr->font, " ", 1);
+ space_width = ZnTextWidth(fptr->font, " ", 1);
- ComputeFieldTextLocation(field_ptr, &field_bbox, &text_pos, &text_bbox);
+ ComputeFieldTextLocation(fptr, &field_bbox, &text_pos, &text_bbox);
/*
* Correct adjusments made by ComputeFieldTextLocation (Vincent Pomey).
*
@@ -693,14 +693,14 @@ LeaderToLabel(FieldSet field_set,
* 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.
- * text_bbox.x -= field_ptr->font->per_char[field_ptr->text[0]].lbearing + 3;
- * text_bbox.width += field_ptr->font->per_char[field_ptr->text[0]].lbearing + 3;
+ * text_bbox.x -= fptr->font->per_char[fptr->text[0]].lbearing + 3;
+ * text_bbox.width += fptr->font->per_char[fptr->text[0]].lbearing + 3;
*/
/*
* Change bbox according to leading and trailing spaces.
*/
scan_forw = 0;
- while (field_ptr->text[scan_forw] == ' ') {
+ while (fptr->text[scan_forw] == ' ') {
/* leading spaces */
text_bbox.orig.x += space_width;
scan_forw++;
@@ -709,12 +709,12 @@ LeaderToLabel(FieldSet field_set,
/*
* Empty text.
*/
- if (!field_ptr->text || (field_ptr->text[scan_forw] == 0)) {
+ if (!fptr->text || (fptr->text[scan_forw] == 0)) {
continue;
}
- scan_back = strlen(field_ptr->text)-1;
- while ((field_ptr->text[scan_back] == ' ') && (scan_back > scan_forw)) {
+ 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--;
@@ -939,7 +939,7 @@ ConfigureField(FieldSet fs,
int *flags)
{
int i;
- Field field_ptr;
+ Field fptr;
ZnBBox bbox;
WidgetInfo *wi = fs->item->wi;
XColor *color;
@@ -953,23 +953,23 @@ ConfigureField(FieldSet fs,
return ZN_ERROR;
}
- field_ptr = &fs->fields[field];
+ fptr = &fs->fields[field];
#ifdef GLX
- old_font = field_ptr->font;
+ old_font = fptr->font;
#endif
old_num_chars = 0;
- if (field_ptr->text) {
- old_num_chars = strlen(field_ptr->text);
+ if (fptr->text) {
+ old_num_chars = Tcl_NumUtfChars(fptr->text, strlen(fptr->text));
}
- if (ZnConfigureAttributes(wi, field_ptr, field_attrs,
+ if (ZnConfigureAttributes(wi, fptr, field_attrs,
argc, argv, flags) == ZN_ERROR) {
return ZN_ERROR;
}
num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
+ if (fptr->text) {
+ num_chars = Tcl_NumUtfChars(fptr->text, strlen(fptr->text));
}
if (old_num_chars != num_chars) {
TextInfo *ti = &wi->text_info;
@@ -990,21 +990,21 @@ ConfigureField(FieldSet fs,
ti->sel_anchor = num_chars;
}
}
- if (field_ptr->insert_index > num_chars) {
- field_ptr->insert_index = num_chars;
+ if (fptr->insert_index > num_chars) {
+ fptr->insert_index = num_chars;
}
}
#ifdef GLX
- if (old_font != field_ptr->font) {
- if (field_ptr->tfi) {
- ZnFreeTexFont(field_ptr->tfi);
+ if (old_font != fptr->font) {
+ if (fptr->tfi) {
+ ZnFreeTexFont(fptr->tfi);
}
if (wi->render) {
- field_ptr->tfi = ZnGetTexFont(wi, field_ptr->font);
- if (!field_ptr->tfi) {
+ fptr->tfi = ZnGetTexFont(wi, fptr->font);
+ if (!fptr->tfi) {
Tcl_AppendResult(wi->interp, "impossible to get the texture for font \"",
- Tk_NameOfFont(field_ptr->font), "\"", NULL);
+ Tk_NameOfFont(fptr->font), "\"", NULL);
return ZN_ERROR;
}
}
@@ -1018,16 +1018,16 @@ ConfigureField(FieldSet fs,
ClearFieldCache(fs, field);
}
- if (field_ptr->gradient &&
- (ISSET(*flags, ZN_BORDER_FLAG) || (field_ptr->relief == RELIEF_FLAT))) {
- ZnFreeGradient(field_ptr->gradient);
- field_ptr->gradient = NULL;
- }
- if ((field_ptr->relief != RELIEF_FLAT) && !field_ptr->gradient) {
- color = ZnGetGradientColor(field_ptr->border_color, 51.0, &alpha);
- field_ptr->gradient = ZnGetReliefGradient(wi->interp, wi->win,
+ if (fptr->gradient &&
+ (ISSET(*flags, ZN_BORDER_FLAG) || (fptr->relief == RELIEF_FLAT))) {
+ ZnFreeGradient(fptr->gradient);
+ fptr->gradient = NULL;
+ }
+ if ((fptr->relief != RELIEF_FLAT) && !fptr->gradient) {
+ color = ZnGetGradientColor(fptr->border_color, 51.0, &alpha);
+ fptr->gradient = ZnGetReliefGradient(wi->interp, wi->win,
ZnNameOfColor(color), alpha);
- if (field_ptr->gradient == NULL) {
+ if (fptr->gradient == NULL) {
return ZN_ERROR;
}
}
@@ -1155,24 +1155,25 @@ FieldPointToChar(FieldSet fs,
int x,
int y)
{
- Field field_ptr;
- int num_chars;
+ Field fptr;
+ int num_bytes, byte_index;
ZnBBox f_bbox, t_bbox;
ZnPoint t_orig;
int n, dummy;
- field_ptr = &fs->fields[field];
- num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
+ fptr = &fs->fields[field];
+ num_bytes = 0;
+ byte_index = 0;
+ if (fptr->text) {
+ num_bytes = strlen(fptr->text);
}
- if (num_chars == 0) {
+ if (num_bytes == 0) {
return 0;
}
GetFieldBBox(fs, field, &f_bbox);
- ComputeFieldTextLocation(field_ptr, &f_bbox, &t_orig, &t_bbox);
+ ComputeFieldTextLocation(fptr, &f_bbox, &t_orig, &t_bbox);
/*
* Point above text, returns index 0.
@@ -1194,17 +1195,21 @@ FieldPointToChar(FieldSet fs,
* Point to the right of the current line, returns
* index past the last char.
*/
- return num_chars;
+ byte_index = num_bytes;
+ goto convrt;
}
- n = Tk_MeasureChars(field_ptr->font, field_ptr->text, num_chars,
+ n = Tk_MeasureChars(fptr->font, fptr->text, num_bytes,
x + 2 - t_bbox.orig.x, TK_PARTIAL_OK, &dummy);
- return n - 1;
+ byte_index = n - 1;
+ goto convrt;
}
/*
* Point below all lines, return the index after
* the last char.
*/
- return num_chars;
+ convrt:
+ byte_index = num_bytes;
+ return Tcl_NumUtfChars(fptr->text, byte_index);
}
static int
@@ -1218,25 +1223,24 @@ WordMoveFromIndex(char *text,
return index;
}
+ strp = Tcl_UtfAtIndex(text, index);
if (fwd) {
- strp = &text[index];
while ((strp[1] == ' ') || (strp[1] == '\n')) {
strp++;
}
while ((strp[1] != ' ') && (strp[1] != '\n') && strp[1]) {
strp++;
}
- return strp + 1 - text;
+ return Tcl_NumUtfChars(text, strp + 1 - text);
}
else {
- strp = &text[index];
- while (((strp[-1] == ' ') || (strp[-1] == '\n')) && (strp != text)) {
+ while ((strp != text) && ((strp[-1] == ' ') || (strp[-1] == '\n'))) {
strp--;
}
- while ((strp[-1] != ' ') && (strp[-1] != '\n') && (strp != text)) {
+ while ((strp != text) && (strp[-1] != ' ') && (strp[-1] != '\n')) {
strp--;
}
- return strp - text;
+ return Tcl_NumUtfChars(text, strp - text);
}
}
@@ -1246,8 +1250,7 @@ FieldIndex(FieldSet fs,
Tcl_Obj *index_spec,
int *index)
{
- Field field_ptr;
- int num_chars;
+ Field fptr;
WidgetInfo *wi = fs->item->wi;
TextInfo *ti = &wi->text_info;
int c, length;
@@ -1260,39 +1263,35 @@ FieldIndex(FieldSet fs,
return ZN_OK;
}
- field_ptr = &fs->fields[field];
- num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
- }
+ fptr = &fs->fields[field];
p = Tcl_GetString(index_spec);
c = p[0];
length = strlen(p);
if ((c == 'e') && (strncmp(p, "end", length) == 0)) {
- *index = num_chars;
+ *index = fptr->text?Tcl_NumUtfChars(fptr->text, strlen(fptr->text)):0;
}
else if ((c == 'e') && (length > 1) && (strncmp(p, "eol", length) == 0)) {
- *index = num_chars;
+ *index = fptr->text?Tcl_NumUtfChars(fptr->text, strlen(fptr->text)):0;
}
else if ((c == 'b') && (length > 1) && (strncmp(p, "bol", length) == 0)) {
*index = 0;
}
else if ((c == 'e') && (length > 1) && (strncmp(p, "eow", length) == 0)) {
- *index = WordMoveFromIndex(field_ptr->text, field_ptr->insert_index, 1);
+ *index = WordMoveFromIndex(fptr->text, fptr->insert_index, 1);
}
else if ((c == 'b') && (length > 1) && (strncmp(p, "bow", length) == 0)) {
- *index = WordMoveFromIndex(field_ptr->text, field_ptr->insert_index, 0);
+ *index = WordMoveFromIndex(fptr->text, fptr->insert_index, 0);
}
else if ((c == 'u') && (strncmp(p, "up", length) == 0)) {
- *index = field_ptr->insert_index;
+ *index = fptr->insert_index;
}
else if ((c == 'd') && (strncmp(p, "down", length) == 0)) {
- *index = field_ptr->insert_index;
+ *index = fptr->insert_index;
}
else if ((c == 'i') && (strncmp(p, "insert", length) == 0)) {
- *index = field_ptr->insert_index;
+ *index = fptr->insert_index;
}
else if ((c == 's') && (strncmp(p, "sel.first", length) == 0) &&
(length >= 5)) {
@@ -1332,6 +1331,7 @@ FieldIndex(FieldSet fs,
*index = FieldPointToChar(fs, field, x, y);
}
else if (Tcl_GetIntFromObj(wi->interp, index_spec, index) == TCL_OK) {
+ int num_chars = fptr->text?Tcl_NumUtfChars(fptr->text, strlen(fptr->text)):0;
if (*index < 0){
*index = 0;
}
@@ -1354,24 +1354,26 @@ FieldInsertChars(FieldSet fs,
int *index,
char *chars)
{
- Field field_ptr;
- int num_chars;
- int length;
+ Field fptr;
+ TextInfo *ti = &fs->item->wi->text_info;
+ int num_chars, num_bytes, chars_added;
+ int byte_index, bytes_added = strlen(chars);
char *new;
if ((field == ZN_NO_PART) || (field >= fs->num_fields)) {
return False;
}
- length = strlen(chars);
- if (length == 0) {
+ if (bytes_added == 0) {
return False;
}
- field_ptr = &fs->fields[field];
+ fptr = &fs->fields[field];
num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
+ num_bytes = 0;
+ if (fptr->text) {
+ num_bytes = strlen(fptr->text);
+ num_chars = Tcl_NumUtfChars(fptr->text, num_bytes);
}
if (*index < 0) {
*index = 0;
@@ -1379,25 +1381,39 @@ FieldInsertChars(FieldSet fs,
if (*index > num_chars) {
*index = num_chars;
}
-
- new = ZnMalloc(num_chars + length + 1);
- if (num_chars) {
+ byte_index = Tcl_UtfAtIndex(fptr->text, *index)-fptr->text;
+ chars_added = Tcl_NumUtfChars(chars, bytes_added);
+
+ new = ZnMalloc(num_bytes + bytes_added + 1);
+ if (fptr->text) {
/*
* Copy the part before and the part after the new
* text (if any).
*/
- strncpy(new, field_ptr->text, (size_t) *index);
- strcpy(new + *index + length, field_ptr->text + *index);
- ZnFree(field_ptr->text);
+ memcpy(new, fptr->text, (size_t) byte_index);
+ strcpy(new + byte_index + bytes_added, fptr->text + byte_index);
+ ZnFree(fptr->text);
}
/*
* Insert the new text.
*/
- strcpy(new + *index, chars);
- field_ptr->text = new;
+ strcpy(new + byte_index, chars);
+ fptr->text = new;
- if (field_ptr->insert_index >= *index) {
- field_ptr->insert_index += length;
+ if (fptr->insert_index >= *index) {
+ fptr->insert_index += chars_added;
+ }
+ if ((ti->sel_item == fs->item) && (ti->sel_field == field)) {
+ if (ti->sel_first >= *index) {
+ ti->sel_first += chars_added;
+ }
+ if (ti->sel_last >= *index) {
+ ti->sel_last += chars_added;
+ }
+ if ((ti->anchor_item == fs->item) && (ti->anchor_field == field) &&
+ (ti->sel_anchor >= *index)) {
+ ti->sel_anchor += chars_added;
+ }
}
/*
@@ -1413,18 +1429,22 @@ FieldDeleteChars(FieldSet fs,
int *first,
int *last)
{
- Field field_ptr;
- int count, num_chars;
- char *new;
+ Field fptr;
+ TextInfo *ti = &fs->item->wi->text_info;
+ int char_count, byte_count;
+ int num_bytes, num_chars, first_offset;
+ char *new;
if ((field == ZN_NO_PART) || (field >= fs->num_fields)) {
return False;
}
- field_ptr = &fs->fields[field];
+ fptr = &fs->fields[field];
num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
+ num_bytes = 0;
+ if (fptr->text) {
+ num_bytes = strlen(fptr->text);
+ num_chars = Tcl_NumUtfChars(fptr->text, num_bytes);
}
if (num_chars == 0) {
return False;
@@ -1439,27 +1459,54 @@ FieldDeleteChars(FieldSet fs,
if (*first > *last) {
return False;
}
- count = *last + 1 - *first;
+ char_count = *last + 1 - *first;
+ first_offset = Tcl_UtfAtIndex(fptr->text, *first)-fptr->text;
+ byte_count = Tcl_UtfAtIndex(fptr->text + first_offset, char_count)-
+ (fptr->text+first_offset);
- if (num_chars - count) {
- new = ZnMalloc(num_chars + 1 - count);
- strncpy(new, field_ptr->text, (size_t) *first);
- strcpy(new + *first, field_ptr->text + *last + 1);
- ZnFree(field_ptr->text);
- field_ptr->text = new;
+ if (num_bytes - byte_count) {
+ new = ZnMalloc(num_bytes + 1 - byte_count);
+ memcpy(new, fptr->text, (size_t) first_offset);
+ strcpy(new + first_offset, fptr->text + first_offset + byte_count);
+ ZnFree(fptr->text);
+ fptr->text = new;
}
else {
- ZnFree(field_ptr->text);
- field_ptr->text = NULL;
+ ZnFree(fptr->text);
+ fptr->text = NULL;
}
/*
* Update the cursor to reflect the new string.
*/
- if (field_ptr->insert_index > *first) {
- field_ptr->insert_index -= count;
- if (field_ptr->insert_index < *first) {
- field_ptr->insert_index = *first;
+ if (fptr->insert_index > *first) {
+ fptr->insert_index -= char_count;
+ if (fptr->insert_index < *first) {
+ fptr->insert_index = *first;
+ }
+ }
+ if ((ti->sel_item == fs->item) && (ti->sel_field == field)) {
+ if (ti->sel_first > *first) {
+ ti->sel_first -= char_count;
+ if (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;
+ }
+ }
+ 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 -= char_count;
+ if (ti->sel_anchor < *first) {
+ ti->sel_anchor = *first;
+ }
}
}
@@ -1475,27 +1522,27 @@ FieldCursor(FieldSet fs,
int field,
int index)
{
- Field field_ptr;
+ Field fptr;
int num_chars;
if ((field == ZN_NO_PART) || (field >= fs->num_fields)) {
return;
}
- field_ptr = &fs->fields[field];
+ fptr = &fs->fields[field];
num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
+ if (fptr->text) {
+ num_chars = Tcl_NumUtfChars(fptr->text, strlen(fptr->text));
}
if (index < 0) {
- field_ptr->insert_index = 0;
+ fptr->insert_index = 0;
}
else if (index > num_chars) {
- field_ptr->insert_index = num_chars;
+ fptr->insert_index = num_chars;
}
else {
- field_ptr->insert_index = index;
+ fptr->insert_index = index;
}
}
@@ -1504,34 +1551,38 @@ FieldSelection(FieldSet fs,
int field,
int offset,
char *chars,
- int max_chars)
+ int max_bytes)
{
- Field field_ptr;
- int count, num_chars;
+ Field fptr;
+ int count;
+ char *sel_first, *sel_last;
TextInfo *ti;
if ((field == ZN_NO_PART) || (field >= fs->num_fields)) {
return 0;
}
-
ti = &fs->item->wi->text_info;
- count = ti->sel_last - ti->sel_first - offset;
- if (count > max_chars) {
- count = max_chars;
- }
- field_ptr = &fs->fields[field];
- num_chars = 0;
- if (field_ptr->text) {
- num_chars = strlen(field_ptr->text);
+ if ((ti->sel_first < 0) ||
+ (ti->sel_first > ti->sel_last)) {
+ return 0;
}
- if (count > num_chars) {
- count = num_chars;
+
+ fptr = &fs->fields[field];
+ if (!fptr->text) {
+ return 0;
}
+
+ sel_first = Tcl_UtfAtIndex(fptr->text, ti->sel_first);
+ sel_last = Tcl_UtfAtIndex(sel_first, ti->sel_last + 1 - ti->sel_first);
+ count = sel_last - sel_first - offset;
if (count <= 0) {
return 0;
}
+ if (count > max_bytes) {
+ count = max_bytes;
+ }
- strncpy(chars, field_ptr->text + ti->sel_first + offset, (size_t) count);
+ memcpy(chars, sel_first + offset, (size_t) count);
chars[count] = 0;
return count;
@@ -1548,17 +1599,17 @@ FieldSelection(FieldSet fs,
**********************************************************************************
*/
static void
-ComputeFieldImageLocation(Field field_ptr,
+ComputeFieldImageLocation(Field fptr,
ZnBBox *bbox,
ZnBBox *pm_bbox)
{
int width, height;
- ZnSizeOfImage(field_ptr->image, &width, &height);
+ ZnSizeOfImage(fptr->image, &width, &height);
pm_bbox->orig.y = (bbox->orig.y + bbox->corner.y - height) / 2;
pm_bbox->corner.y = pm_bbox->orig.y + height;
- switch (field_ptr->alignment) {
+ switch (fptr->alignment) {
case ZnJustifyLeft:
pm_bbox->orig.x = bbox->orig.x;
break;
@@ -1587,7 +1638,7 @@ FieldsEngine(FieldSet field_set,
WidgetInfo *wi = field_set->item->wi;
int i; /* This one *NEED* to be an int */
int num_fields, num_chars;
- Field field_ptr;
+ Field fptr;
TextInfo *ti = &wi->text_info;
ZnBBox lclip_bbox, fclip_bbox, bbox, *global_clip_box;
ZnBBox tmp_bbox, text_bbox, pm_bbox;
@@ -1624,9 +1675,9 @@ FieldsEngine(FieldSet field_set,
num_fields = LabelFormatNumFields(field_set->label_format);
for (i = 0; i < num_fields; i++) {
- field_ptr = &field_set->fields[i];
+ fptr = &field_set->fields[i];
- if (ISCLEAR(field_ptr->flags, FIELD_VISIBLE_BIT)) {
+ if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT)) {
continue;
}
@@ -1649,21 +1700,24 @@ FieldsEngine(FieldSet field_set,
cursor = -1;
sel_start = -1, sel_stop = -1;
- if (field_ptr->text) {
+ if (fptr->text) {
if ((field_set->item == wi->focus_item) &&
(wi->focus_field == i) && wi->got_focus && ti->cursor_on) {
- cursor = Tk_TextWidth(field_ptr->font, field_ptr->text,
- field_ptr->insert_index);
+ cursor = Tk_TextWidth(fptr->font, fptr->text,
+ Tcl_UtfAtIndex(fptr->text,
+ fptr->insert_index)-fptr->text);
}
- ComputeFieldTextLocation(field_ptr, &bbox, &text_pos, &text_bbox);
- num_chars = strlen(field_ptr->text);
+ ComputeFieldTextLocation(fptr, &bbox, &text_pos, &text_bbox);
+ num_chars = Tcl_NumUtfChars(fptr->text, strlen(fptr->text));
if (num_chars) {
if ((field_set->item == ti->sel_item) && (ti->sel_field == i) &&
(ti->sel_last >= 0) && (ti->sel_first <= num_chars)) {
- sel_start = Tk_TextWidth(field_ptr->font,
- field_ptr->text, ti->sel_first);
- sel_stop = Tk_TextWidth(field_ptr->font,
- field_ptr->text, ti->sel_last);
+ 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);
}
IntersectBBox(&fclip_bbox, &text_bbox, &tmp_bbox);
@@ -1679,8 +1733,8 @@ FieldsEngine(FieldSet field_set,
}
}
- if (field_ptr->image != ZnUnspecifiedImage) {
- ComputeFieldImageLocation(field_ptr, &bbox, &pm_bbox);
+ if (fptr->image != ZnUnspecifiedImage) {
+ ComputeFieldImageLocation(fptr, &bbox, &pm_bbox);
IntersectBBox(&fclip_bbox, &pm_bbox, &tmp_bbox);
@@ -1704,7 +1758,7 @@ FieldsEngine(FieldSet field_set,
ZnPushClip(wi, &tristrip, True, True);
}
- (*cb)(wi, field_ptr, &bbox, &pm_bbox,
+ (*cb)(wi, fptr, &bbox, &pm_bbox,
&text_pos, &text_bbox, cursor, sel_start, sel_stop);
if (restore) {
@@ -1726,7 +1780,7 @@ FieldsEngine(FieldSet field_set,
*/
static void
DrawField(WidgetInfo *wi,
- Field field_ptr,
+ Field fptr,
ZnBBox *bbox,
ZnBBox *pm_bbox,
ZnPoint *text_pos,
@@ -1738,7 +1792,7 @@ DrawField(WidgetInfo *wi,
TextInfo *ti = &wi->text_info;
XGCValues values;
XRectangle r;
- int j, xs, num_chars;
+ int j, xs, num_bytes;
int pw, ph, fw, fh;
Region clip_region;
ZnBool simple;
@@ -1749,21 +1803,21 @@ DrawField(WidgetInfo *wi,
/*
* Draw the background.
*/
- if (ISSET(field_ptr->flags, FILLED_BIT)) {
- values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->fill_color, 0.0, NULL));
+ if (ISSET(fptr->flags, FILLED_BIT)) {
+ values.foreground = ZnPixel(ZnGetGradientColor(fptr->fill_color, 0.0, NULL));
- if (field_ptr->tile != ZnUnspecifiedImage) { /* Fill tiled */
+ if (fptr->tile != ZnUnspecifiedImage) { /* Fill tiled */
values.fill_style = FillTiled;
- values.tile = ZnImagePixmap(field_ptr->tile, NULL);
+ values.tile = ZnImagePixmap(fptr->tile, NULL);
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 if (field_ptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
+ else if (fptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(field_ptr->fill_pattern, NULL);
+ values.stipple = ZnImagePixmap(fptr->fill_pattern, NULL);
values.ts_x_origin = (int) bbox->orig.x;
values.ts_y_origin = (int) bbox->orig.y;
XChangeGC(wi->dpy, wi->gc,
@@ -1782,13 +1836,13 @@ DrawField(WidgetInfo *wi,
* the value of text_on_top.
*/
for (j = 0; j < 2; j++) {
- if ((j == 0 && ISSET(field_ptr->flags, TEXT_ON_TOP_BIT)) ||
- (j == 1 && ISCLEAR(field_ptr->flags, TEXT_ON_TOP_BIT))) {
+ if ((j == 0 && ISSET(fptr->flags, TEXT_ON_TOP_BIT)) ||
+ (j == 1 && ISCLEAR(fptr->flags, TEXT_ON_TOP_BIT))) {
/*
* Draw the image.
*/
- if (field_ptr->image != ZnUnspecifiedImage) {
- pixmap = ZnImagePixmap(field_ptr->image, &mask_pmap);
+ if (fptr->image != ZnUnspecifiedImage) {
+ pixmap = ZnImagePixmap(fptr->image, &mask_pmap);
if (mask_pmap != ZnUnspecifiedImage) {
ZnCurrentClip(wi, &clip_region, NULL, &simple);
XSetClipMask(wi->dpy, wi->gc, mask_pmap);
@@ -1815,12 +1869,12 @@ DrawField(WidgetInfo *wi,
}
}
}
- else if (field_ptr->text) {
+ else if (fptr->text) {
/*
* Draw the text.
*/
- num_chars = strlen(field_ptr->text);
- if (num_chars) {
+ num_bytes = strlen(fptr->text);
+ if (num_bytes) {
if (sel_start >= 0) {
values.foreground = ZnPixel(ZnGetGradientColor(ti->sel_color, 0, NULL));
values.fill_style = FillSolid;
@@ -1830,13 +1884,12 @@ DrawField(WidgetInfo *wi,
sel_stop-sel_start,
text_bbox->corner.y-text_bbox->orig.y);
}
- values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->color, 0, NULL));
+ values.foreground = ZnPixel(ZnGetGradientColor(fptr->color, 0, NULL));
values.fill_style = FillSolid;
- values.font = ZnFontId(field_ptr->font);
+ values.font = ZnFontId(fptr->font);
XChangeGC(wi->dpy, wi->gc, GCForeground | GCFillStyle | GCFont, &values);
- Tk_DrawChars(wi->dpy, wi->draw_buffer, wi->gc, field_ptr->font,
- field_ptr->text, num_chars,
- text_pos->x, text_pos->y);
+ Tk_DrawChars(wi->dpy, wi->draw_buffer, wi->gc, fptr->font,
+ fptr->text, num_bytes, text_pos->x, text_pos->y);
}
if (cursor >= 0) {
values.line_width = ti->insert_width;
@@ -1854,44 +1907,44 @@ DrawField(WidgetInfo *wi,
/*
* Draw the border relief.
*/
- if ((field_ptr->relief != RELIEF_FLAT) && (field_ptr->relief_thickness > 1)) {
- ZnDrawRectangleRelief(wi, field_ptr->relief, field_ptr->gradient,
- &r, (unsigned int) field_ptr->relief_thickness);
+ if ((fptr->relief != RELIEF_FLAT) && (fptr->relief_thickness > 1)) {
+ ZnDrawRectangleRelief(wi, fptr->relief, fptr->gradient,
+ &r, (unsigned int) fptr->relief_thickness);
}
/*
* Draw the border line.
*/
- if (field_ptr->border_edges != NO_BORDER) {
- values.foreground = ZnPixel(ZnGetGradientColor(field_ptr->border_color, 0, NULL));
+ if (fptr->border_edges != NO_BORDER) {
+ values.foreground = ZnPixel(ZnGetGradientColor(fptr->border_color, 0, NULL));
values.line_width = 0;
values.line_style = LineSolid;
values.fill_style = FillSolid;
XChangeGC(wi->dpy, wi->gc,
GCForeground | GCLineWidth | GCLineStyle | GCFillStyle, &values);
- if (field_ptr->border_edges & LEFT_BORDER) {
+ if (fptr->border_edges & LEFT_BORDER) {
XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, r.x, r.y,
r.x, r.y + r.height - 1);
}
- if (field_ptr->border_edges & RIGHT_BORDER) {
+ if (fptr->border_edges & 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);
}
- if (field_ptr->border_edges & TOP_BORDER) {
+ if (fptr->border_edges & TOP_BORDER) {
XDrawLine(wi->dpy, wi->draw_buffer, wi->gc,
r.x, r.y, r.x + r.width - 1, r.y);
}
- if (field_ptr->border_edges & BOTTOM_BORDER) {
+ if (fptr->border_edges & 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);
}
- if (field_ptr->border_edges & OBLIQUE) {
+ if (fptr->border_edges & OBLIQUE) {
XDrawLine(wi->dpy, wi->draw_buffer, wi->gc,
r.x, r.y, r.x + r.width - 1, r.y + r.height - 1);
}
- if (field_ptr->border_edges & COUNTER_OBLIQUE) {
+ if (fptr->border_edges & COUNTER_OBLIQUE) {
XDrawLine(wi->dpy, wi->draw_buffer, wi->gc,
r.x, r.y + r.height - 1,
r.x + r.width - 1, r.y);
@@ -1930,7 +1983,7 @@ FieldRenderCB(void *closure)
static void
RenderField(WidgetInfo *wi,
- Field field_ptr,
+ Field fptr,
ZnBBox *bbox,
ZnBBox *pm_bbox,
ZnPoint *text_pos,
@@ -1940,7 +1993,7 @@ RenderField(WidgetInfo *wi,
int sel_stop)
{
#ifdef GLX
- int j, alpha, num_chars;
+ int j, alpha, num_bytes;
XColor *color;
ZnReal xs;
TextInfo *ti = &wi->text_info;
@@ -1948,32 +2001,32 @@ RenderField(WidgetInfo *wi,
/*
* Draw the background.
*/
- if (ISSET(field_ptr->flags, FILLED_BIT)) {
+ if (ISSET(fptr->flags, FILLED_BIT)) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- if (!ZnGradientFlat(field_ptr->fill_color)) {
+ if (!ZnGradientFlat(fptr->fill_color)) {
#if 0 /* TODO_GLX Faire le dégradé dans le fond des champs. */
- int type = field_ptr->fill_color->type;
- ZnBool fast = (type == ZN_AXIAL_GRADIENT) && !field_ptr->grad_geo;
+ int type = fptr->fill_color->type;
+ ZnBool fast = (type == ZN_AXIAL_GRADIENT) && !fptr->grad_geo;
- RenderGradient(wi, field_ptr->fill_color,
+ RenderGradient(wi, fptr->fill_color,
fast ? NULL : FieldRenderCB,
- bbox, fast ? (ZnPoint *) bbox : field_ptr->grad_geo);
+ bbox, fast ? (ZnPoint *) bbox : fptr->grad_geo);
#endif
}
else {
- if (field_ptr->tile != ZnUnspecifiedImage) { /* Fill tiled */
- ZnRenderTile(wi, field_ptr->tile, field_ptr->fill_color, FieldRenderCB, bbox,
+ if (fptr->tile != ZnUnspecifiedImage) { /* Fill tiled */
+ ZnRenderTile(wi, fptr->tile, fptr->fill_color, FieldRenderCB, bbox,
(ZnPoint *) bbox);
}
else { /* Fill solid */
- if (field_ptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
+ if (fptr->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
/*
* Setup polygon stippling.
*/
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(ZnImagePattern(field_ptr->fill_pattern, NULL));
+ glPolygonStipple(ZnImagePattern(fptr->fill_pattern, NULL));
}
- color = ZnGetGradientColor(field_ptr->fill_color, 0.0, &alpha);
+ color = ZnGetGradientColor(fptr->fill_color, 0.0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
FieldRenderCB(bbox);
@@ -1987,23 +2040,23 @@ RenderField(WidgetInfo *wi,
* the value of text_on_top.
*/
for (j = 0; j < 2; j++) {
- if ((j == 0 && ISSET(field_ptr->flags, TEXT_ON_TOP_BIT)) ||
- (j == 1 && ISCLEAR(field_ptr->flags, TEXT_ON_TOP_BIT))) {
+ if ((j == 0 && ISSET(fptr->flags, TEXT_ON_TOP_BIT)) ||
+ (j == 1 && ISCLEAR(fptr->flags, TEXT_ON_TOP_BIT))) {
/*
* Draw the image.
*/
- if (field_ptr->image != ZnUnspecifiedImage) {
- ZnRenderIcon(wi, field_ptr->image, field_ptr->fill_color,
+ if (fptr->image != ZnUnspecifiedImage) {
+ ZnRenderIcon(wi, fptr->image, fptr->fill_color,
&pm_bbox->orig, False);
}
}
- else if (field_ptr->text) {
+ else if (fptr->text) {
/*
* Draw the text.
*/
- num_chars = strlen(field_ptr->text);
- if (num_chars) {
- if (field_ptr->tfi) {
+ num_bytes = strlen(fptr->text);
+ if (num_bytes) {
+ if (fptr->tfi) {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (sel_start >= 0) {
color = ZnGetGradientColor(ti->sel_color, 0, &alpha);
@@ -2018,13 +2071,13 @@ RenderField(WidgetInfo *wi,
}
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- color = ZnGetGradientColor(field_ptr->color, 0, &alpha);
+ color = ZnGetGradientColor(fptr->color, 0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
- glBindTexture(GL_TEXTURE_2D, ZnTexFontTex(field_ptr->tfi));
+ glBindTexture(GL_TEXTURE_2D, ZnTexFontTex(fptr->tfi));
glPushMatrix();
glTranslatef(text_pos->x, text_pos->y, 0.0);
- ZnRenderString(field_ptr->tfi, field_ptr->text, num_chars);
+ ZnRenderString(fptr->tfi, fptr->text, num_bytes);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}
@@ -2046,7 +2099,7 @@ RenderField(WidgetInfo *wi,
/*
* Draw the border relief.
*/
- if ((field_ptr->relief != RELIEF_FLAT) && (field_ptr->relief_thickness > 1)) {
+ if ((fptr->relief != RELIEF_FLAT) && (fptr->relief_thickness > 1)) {
ZnPoint p[5];
p[0].x = bbox->orig.x;
@@ -2058,41 +2111,41 @@ RenderField(WidgetInfo *wi,
p[3].x = p[2].x;
p[3].y = p[0].y;
p[4] = p[0];
- ZnRenderPolygonRelief(wi, field_ptr->relief, field_ptr->gradient,
- False, p, 5, field_ptr->relief_thickness);
+ ZnRenderPolygonRelief(wi, fptr->relief, fptr->gradient,
+ False, p, 5, fptr->relief_thickness);
}
/*
* Draw the border line.
*/
- if (field_ptr->border_edges != NO_BORDER) {
- color = ZnGetGradientColor(field_ptr->border_color, 0, &alpha);
+ if (fptr->border_edges != NO_BORDER) {
+ color = ZnGetGradientColor(fptr->border_color, 0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
glColor4us(color->red, color->green, color->blue, alpha);
glLineWidth(1.5);
ZnSetLineStyle(wi, LINE_SIMPLE);
glBegin(GL_LINES);
- if (field_ptr->border_edges & LEFT_BORDER) {
+ if (fptr->border_edges & LEFT_BORDER) {
glVertex2f(bbox->orig.x, bbox->orig.y);
glVertex2f(bbox->orig.x, bbox->corner.y);
}
- if (field_ptr->border_edges & RIGHT_BORDER) {
+ if (fptr->border_edges & RIGHT_BORDER) {
glVertex2f(bbox->corner.x, bbox->orig.y);
glVertex2f(bbox->corner.x, bbox->corner.y);
}
- if (field_ptr->border_edges & TOP_BORDER) {
+ if (fptr->border_edges & TOP_BORDER) {
glVertex2f(bbox->orig.x, bbox->orig.y);
glVertex2f(bbox->corner.x, bbox->orig.y);
}
- if (field_ptr->border_edges & BOTTOM_BORDER) {
+ if (fptr->border_edges & BOTTOM_BORDER) {
glVertex2f(bbox->orig.x, bbox->corner.y);
glVertex2f(bbox->corner.x, bbox->corner.y);
}
- if (field_ptr->border_edges & OBLIQUE) {
+ if (fptr->border_edges & OBLIQUE) {
glVertex2f(bbox->orig.x, bbox->orig.y);
glVertex2f(bbox->corner.x, bbox->corner.y);
}
- if (field_ptr->border_edges & COUNTER_OBLIQUE) {
+ if (fptr->border_edges & COUNTER_OBLIQUE) {
glVertex2f(bbox->orig.x, bbox->corner.y);
glVertex2f(bbox->corner.x, bbox->orig.y);
}
@@ -2147,7 +2200,7 @@ FieldsPick(FieldSet field_set,
ZnPoint *p,
int *part)
{
- Field field_ptr;
+ Field fptr;
ZnBBox bbox;
int i, best_field = 0;
double new_dist, dist = 1e40;
@@ -2158,10 +2211,10 @@ FieldsPick(FieldSet field_set,
if (field_set->label_format) {
for (i = LabelFormatNumFields(field_set->label_format)-1; i >= 0; i--) {
- field_ptr = &field_set->fields[i];
+ fptr = &field_set->fields[i];
- if (ISCLEAR(field_ptr->flags, FIELD_VISIBLE_BIT) &&
- ISCLEAR(field_ptr->flags, FIELD_SENSITIVE_BIT)) {
+ if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT) &&
+ ISCLEAR(fptr->flags, FIELD_SENSITIVE_BIT)) {
continue;
}
@@ -2198,7 +2251,7 @@ static int
FieldsToArea(FieldSet field_set,
ZnBBox *area)
{
- Field field_ptr;
+ Field fptr;
ZnBBox bbox;
int inside = -1;
int i;
@@ -2209,10 +2262,10 @@ FieldsToArea(FieldSet field_set,
}
for (i = LabelFormatNumFields(field_set->label_format)-1; i >= 0; i--) {
- field_ptr = &field_set->fields[i];
+ fptr = &field_set->fields[i];
- if (ISCLEAR(field_ptr->flags, FIELD_VISIBLE_BIT) &&
- ISCLEAR(field_ptr->flags, FIELD_SENSITIVE_BIT)) {
+ if (ISCLEAR(fptr->flags, FIELD_VISIBLE_BIT) &&
+ ISCLEAR(fptr->flags, FIELD_SENSITIVE_BIT)) {
continue;
}