From ae0cd160ad810b17fdc9d215cf21dc013658dd9c Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 5 Jul 2002 14:29:26 +0000 Subject: * (FieldsEngine): Le curseur n'�tait plus affich� si il n'y avait plus de caract�res. * (FieldsEngine): Le curseur �tait affich� dans tous les champs > au champ actif. --- generic/Field.c | 55 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/generic/Field.c b/generic/Field.c index 25cdeca..3cd5036 100644 --- a/generic/Field.c +++ b/generic/Field.c @@ -1547,7 +1547,7 @@ FieldsEngine(FieldSet field_set, ZnBool restore = False; ZnDim lwidth, lheight; ZnReal val; - int cursor = -1; + int cursor; int sel_start = -1, sel_stop = -1; if (!field_set->num_fields) { @@ -1596,14 +1596,15 @@ FieldsEngine(FieldSet field_set, val = fclip_bbox.corner.y - bbox.corner.y; restore |= val < 0; + cursor = -1; + 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); + } + ComputeFieldTextLocation(field_ptr, &bbox, &text_pos, &text_bbox); num_chars = strlen(field_ptr->text); if (num_chars) { - ComputeFieldTextLocation(field_ptr, &bbox, &text_pos, &text_bbox); - 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); - } 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, @@ -1781,15 +1782,15 @@ DrawField(WidgetInfo *wi, Tk_DrawChars(wi->dpy, wi->draw_buffer, wi->gc, field_ptr->font, field_ptr->text, num_chars, text_pos->x, text_pos->y); - if (cursor >= 0) { - values.line_width = ti->insert_width; - values.foreground = ZnPixel(ZnGetGradientColor(ti->insert_color, 0, NULL)); - XChangeGC(wi->dpy, wi->gc, GCForeground|GCLineWidth, &values); - xs = text_bbox->orig.x + cursor; - XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, - xs, text_bbox->orig.y, - xs, text_bbox->corner.y); - } + } + if (cursor >= 0) { + values.line_width = ti->insert_width; + values.foreground = ZnPixel(ZnGetGradientColor(ti->insert_color, 0, NULL)); + XChangeGC(wi->dpy, wi->gc, GCForeground|GCLineWidth, &values); + xs = text_bbox->orig.x + cursor; + XDrawLine(wi->dpy, wi->draw_buffer, wi->gc, + xs, text_bbox->orig.y, + xs, text_bbox->corner.y); } } } @@ -1970,19 +1971,19 @@ RenderField(WidgetInfo *wi, ZnRenderString(field_ptr->tfi, field_ptr->text, num_chars); glPopMatrix(); glDisable(GL_TEXTURE_2D); - if (cursor >= 0) { - glLineWidth(ti->insert_width); - color = ZnGetGradientColor(ti->insert_color, 0, &alpha); - alpha = ZnComposeAlpha(alpha, wi->alpha); - glColor4us(color->red, color->green, color->blue, alpha); - xs = text_bbox->orig.x + cursor; - glBegin(GL_LINES); - glVertex2f(xs, text_bbox->orig.y); - glVertex2f(xs, text_bbox->corner.y); - glEnd(); - } } } + if (cursor >= 0) { + glLineWidth(ti->insert_width); + color = ZnGetGradientColor(ti->insert_color, 0, &alpha); + alpha = ZnComposeAlpha(alpha, wi->alpha); + glColor4us(color->red, color->green, color->blue, alpha); + xs = text_bbox->orig.x + cursor; + glBegin(GL_LINES); + glVertex2f(xs, text_bbox->orig.y); + glVertex2f(xs, text_bbox->corner.y); + glEnd(); + } } } -- cgit v1.1