summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2012-06-11 08:58:07 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2012-06-11 08:58:07 (GMT)
commitdd043ddda72a07c8d0849c8753b5db649f7c3973 (patch)
tree33712b7ad6496f2b917fc8603d4ac9ea8b111e3a /generic
parent3abdd3fdeca24302282b72d34b2816b282507895 (diff)
parentc733de6f46d26950ed8bc06866e2c5f8aa31a796 (diff)
downloadtk-dd043ddda72a07c8d0849c8753b5db649f7c3973.zip
tk-dd043ddda72a07c8d0849c8753b5db649f7c3973.tar.gz
tk-dd043ddda72a07c8d0849c8753b5db649f7c3973.tar.bz2
[Bug 3294450]: Do clipping of ttk text elements correctly.
Diffstat (limited to 'generic')
-rw-r--r--generic/ttk/ttkLabel.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index 90ed9e7..6abc847 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);