summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2012-06-11 08:57:14 (GMT)
committerdkf <dkf@noemail.net>2012-06-11 08:57:14 (GMT)
commit2abcbbe14b0c28b4c67c637aa1cb50811d8684a8 (patch)
tree245c918ed541c3b979902886d9efcd54b05fb8a1
parent399c2bef0033d19ea41050d129c85cb41c89935f (diff)
downloadtk-2abcbbe14b0c28b4c67c637aa1cb50811d8684a8.zip
tk-2abcbbe14b0c28b4c67c637aa1cb50811d8684a8.tar.gz
tk-2abcbbe14b0c28b4c67c637aa1cb50811d8684a8.tar.bz2
[Bug 3294450]: Do clipping of ttk text elements correctly.
FossilOrigin-Name: bd1d53d6b6bf5afedbc90fcaa5b82abc695c97c2
-rw-r--r--ChangeLog10
-rw-r--r--generic/ttk/ttkLabel.c22
2 files changed, 25 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c389c07..fac93a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +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).
+
2012-06-10 Jan Nijtmans <nijtmans@users.sf.net>
* library/*.tcl: [Bug 3534137]: $tcl_platform(platform) !=
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index 0f773e7..df6a686 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -7,7 +7,7 @@
*/
#include <tcl.h>
-#include <tk.h>
+#include <tkInt.h>
#include "ttkTheme.h"
/*----------------------------------------------------------------------
@@ -128,7 +128,6 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
{
XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj);
int underline = -1;
- int lastChar = -1;
XGCValues gcValues;
GC gc1, gc2;
Tk_Anchor anchor = TK_ANCHOR_CENTER;
@@ -147,21 +146,30 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
/*
* Clip text if it's too wide:
- * @@@ BUG: This will overclip multi-line text.
*/
if (b.width < text->width) {
- lastChar = Tk_PointToChar(text->textLayout, b.width, 1) + 1;
+ TkRegion clipRegion = TkCreateRegion();
+ XRectangle rect;
+
+ rect.x = b.x;
+ rect.y = b.y;
+ rect.width = b.width + (text->embossed ? 1 : 0);
+ rect.height = b.height + (text->embossed ? 1 : 0);
+ TkUnionRectWithRegion(&rect, clipRegion, clipRegion);
+ TkSetRegion(Tk_Display(tkwin), gc1, clipRegion);
+ TkSetRegion(Tk_Display(tkwin), gc2, clipRegion);
+ TkDestroyRegion(clipRegion);
}
if (text->embossed) {
Tk_DrawTextLayout(Tk_Display(tkwin), d, gc2,
- text->textLayout, b.x+1, b.y+1, 0/*firstChar*/, lastChar);
+ text->textLayout, b.x+1, b.y+1, 0/*firstChar*/, -1/*lastChar*/);
}
Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1,
- text->textLayout, b.x, b.y, 0/*firstChar*/, lastChar);
+ text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/);
Tcl_GetIntFromObj(NULL, text->underlineObj, &underline);
- if (underline >= 0 && (lastChar == -1 || underline <= lastChar)) {
+ if (underline >= 0) {
if (text->embossed) {
Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2,
text->textLayout, b.x+1, b.y+1, underline);