aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2005-05-25 08:26:27 +0000
committerlecoanet2005-05-25 08:26:27 +0000
commite96587e7c59b720f8c59aa42cef888dbaf03da3f (patch)
treede094444a1d2d23fbee1325ca49deaae7a28255a
parent6ed591d0ce60e7e942b1678df087ff195ac032a9 (diff)
downloadtkzinc-e96587e7c59b720f8c59aa42cef888dbaf03da3f.zip
tkzinc-e96587e7c59b720f8c59aa42cef888dbaf03da3f.tar.gz
tkzinc-e96587e7c59b720f8c59aa42cef888dbaf03da3f.tar.bz2
tkzinc-e96587e7c59b720f8c59aa42cef888dbaf03da3f.tar.xz
Need to reinstate the GL rendering context after using
Tk_MeasureChars or Tk_TextWidth under windows.
-rw-r--r--generic/Field.c14
-rw-r--r--generic/Text.c2
2 files changed, 13 insertions, 3 deletions
diff --git a/generic/Field.c b/generic/Field.c
index 9f36e88..e0a428f 100644
--- a/generic/Field.c
+++ b/generic/Field.c
@@ -586,7 +586,9 @@ ComputeFieldTextLocation(Field fptr,
Tk_GetFontMetrics(fptr->font, &fm);
w = 0;
if (fptr->text) {
- w = Tk_TextWidth(fptr->font, fptr->text, (int) strlen(fptr->text));
+ int width;
+ Tk_MeasureChars(fptr->font, fptr->text, strlen(fptr->text), -1, 0, &width);
+ w = width;
}
h = fm.ascent + fm.descent;
text_bbox->orig.y = (bbox->orig.y + bbox->corner.y - h) / 2.0;
@@ -1352,11 +1354,11 @@ FieldInsertChars(ZnFieldSet fs,
if (*index > num_chars) {
*index = num_chars;
}
- byte_index = Tcl_UtfAtIndex(fptr->text, *index) - fptr->text;
chars_added = Tcl_NumUtfChars(chars, (int) bytes_added);
- new = ZnMalloc(num_bytes + bytes_added + 1);
if (fptr->text) {
+ byte_index = Tcl_UtfAtIndex(fptr->text, *index) - fptr->text;
+ new = ZnMalloc(num_bytes + bytes_added + 1);
/*
* Copy the part before and the part after the new
* text (if any).
@@ -1365,6 +1367,11 @@ FieldInsertChars(ZnFieldSet fs,
strcpy(new + byte_index + bytes_added, fptr->text + byte_index);
ZnFree(fptr->text);
}
+ else {
+ byte_index = 0;
+ new = ZnMalloc(num_bytes + 1);
+ new[num_bytes] = 0;
+ }
/*
* Insert the new text.
*/
@@ -1986,6 +1993,7 @@ RenderField(ZnWInfo *wi,
ZnReal xs;
ZnTextInfo *ti = &wi->text_info;
+ ZnGLMakeCurrent(wi->dpy, wi);
/*
* Draw the background.
*/
diff --git a/generic/Text.c b/generic/Text.c
index bc7c843..b2e83f8 100644
--- a/generic/Text.c
+++ b/generic/Text.c
@@ -1135,6 +1135,8 @@ Render(ZnItem item)
ComputeCursor(item, &cursor_line, &cursor_offset);
ComputeSelection(item, &sel_first_line, &sel_last_line,
&sel_start_offset, &sel_stop_offset);
+
+ ZnGLMakeCurrent(wi->dpy, wi);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glPushMatrix();