summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--generic/ttk/ttkEntry.c32
2 files changed, 32 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index fac93a0..7ac76d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,13 @@
2012-06-11 Donal K. Fellows <dkf@users.sf.net>
* generic/ttk/ttkLabel.c (TextDraw): [Bug 3294450]: Get the clipping
- of text in Ttk text elements (e.g., buttons, entries, etc.) correct.
- Stops a whole range of visual problems, including loss of the second
- and subsequent lines of a label when the first line doesn't entirely
- fit, and failing to draw the last character of an entry at all if it
- doesn't all exactly fit in the space available (a problem I've noticed
- in tkchat, and been very frustrated with).
+ * generic/ttk/ttkEntry.c (EntryDisplay): of text in Ttk various text
+ elements (e.g., buttons, entries, etc.) correct. Stops a whole range
+ of visual problems, including loss of the second and subsequent lines
+ of a label when the first line doesn't entirely fit, and failing to
+ draw the last character of an entry at all if it doesn't all exactly
+ fit in the space available (a problem I've noticed in tkchat, and been
+ very frustrated with).
2012-06-10 Jan Nijtmans <nijtmans@users.sf.net>
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index c4b1b6a..410c60c 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -10,7 +10,7 @@
#include <string.h>
#include <stdio.h>
-#include <tk.h>
+#include <tkInt.h>
#include <X11/Xatom.h>
#include "ttkTheme.h"
@@ -1123,7 +1123,7 @@ EntryDoLayout(void *recordPtr)
* rightIndex is set to one past the last fully-visible character.
*/
Tk_CharBbox(textLayout, leftIndex, &leftX, NULL, NULL, NULL);
- rightIndex = Tk_PointToChar(textLayout, leftX + textarea.width, 0);
+ rightIndex = Tk_PointToChar(textLayout, leftX + textarea.width, 0)+1;
entryPtr->entry.layoutX = textarea.x - leftX;
}
@@ -1135,13 +1135,14 @@ EntryDoLayout(void *recordPtr)
* Get a GC using the specified foreground color and the entry's font.
* Result must be freed with Tk_FreeGC().
*/
-static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj)
+static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip)
{
Tk_Window tkwin = entryPtr->core.tkwin;
Tk_Font font = Tk_GetFontFromObj(tkwin, entryPtr->entry.fontObj);
XColor *colorPtr;
unsigned long mask = 0ul;
XGCValues gcValues;
+ GC gc;
gcValues.line_width = 1; mask |= GCLineWidth;
gcValues.font = Tk_FontId(font); mask |= GCFont;
@@ -1149,7 +1150,9 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj)
gcValues.foreground = colorPtr->pixel;
mask |= GCForeground;
}
- return Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues);
+ gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues);
+ TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip);
+ return gc;
}
/* EntryDisplay --
@@ -1166,9 +1169,13 @@ static void EntryDisplay(void *clientData, Drawable d)
EntryStyleData es;
GC gc;
int showSelection, showCursor;
+ Ttk_Box textarea;
+ TkRegion clipRegion;
+ XRectangle rect;
EntryInitStyleData(entryPtr, &es);
+ textarea = Ttk_ClientRegion(corePtr->layout, "textarea");
showCursor =
(entryPtr->core.flags & CURSOR_ON) != 0
&& EntryEditable(entryPtr)
@@ -1214,6 +1221,16 @@ static void EntryDisplay(void *clientData, Drawable d)
}
}
+ /* Initialize the clip region:
+ */
+
+ rect.x = textarea.x;
+ rect.y = textarea.y;
+ rect.width = textarea.width;
+ rect.height = textarea.height;
+ clipRegion = TkCreateRegion();
+ TkUnionRectWithRegion(&rect, clipRegion, clipRegion);
+
/* Draw cursor:
*/
if (showCursor) {
@@ -1230,7 +1247,7 @@ static void EntryDisplay(void *clientData, Drawable d)
/* @@@ should: maybe: SetCaretPos even when blinked off */
Tk_SetCaretPos(tkwin, cursorX, cursorY, cursorHeight);
- gc = EntryGetGC(entryPtr, es.insertColorObj);
+ gc = EntryGetGC(entryPtr, es.insertColorObj, clipRegion);
XFillRectangle(Tk_Display(tkwin), d, gc,
cursorX-cursorWidth/2, cursorY, cursorWidth, cursorHeight);
Tk_FreeGC(Tk_Display(tkwin), gc);
@@ -1238,7 +1255,7 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Draw the text:
*/
- gc = EntryGetGC(entryPtr, es.foregroundObj);
+ gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion);
Tk_DrawTextLayout(
Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
entryPtr->entry.layoutX, entryPtr->entry.layoutY,
@@ -1248,13 +1265,14 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Overwrite the selected portion (if any) in the -selectforeground color:
*/
if (showSelection) {
- gc = EntryGetGC(entryPtr, es.selForegroundObj);
+ gc = EntryGetGC(entryPtr, es.selForegroundObj, clipRegion);
Tk_DrawTextLayout(
Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout,
entryPtr->entry.layoutX, entryPtr->entry.layoutY,
selFirst, selLast);
Tk_FreeGC(Tk_Display(tkwin), gc);
}
+ TkDestroyRegion(clipRegion);
}
/*------------------------------------------------------------------------