aboutsummaryrefslogtreecommitdiff
path: root/generic/Field.c
diff options
context:
space:
mode:
authorlecoanet2002-07-05 14:29:26 +0000
committerlecoanet2002-07-05 14:29:26 +0000
commitae0cd160ad810b17fdc9d215cf21dc013658dd9c (patch)
tree9f0998a87d0e2fb07b5367744a371f66993d8822 /generic/Field.c
parentba8620c0f754346a586c47aa2338c74836baf23e (diff)
downloadtkzinc-ae0cd160ad810b17fdc9d215cf21dc013658dd9c.zip
tkzinc-ae0cd160ad810b17fdc9d215cf21dc013658dd9c.tar.gz
tkzinc-ae0cd160ad810b17fdc9d215cf21dc013658dd9c.tar.bz2
tkzinc-ae0cd160ad810b17fdc9d215cf21dc013658dd9c.tar.xz
* (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.
Diffstat (limited to 'generic/Field.c')
-rw-r--r--generic/Field.c55
1 files 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();
+ }
}
}