summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2020-05-01 12:02:54 (GMT)
committerfvogel <fvogelnew1@free.fr>2020-05-01 12:02:54 (GMT)
commit641eafecd32b65ad9d8adfe6803213421a21bef8 (patch)
treee9a2ac7a0693c3517afe465567be3bea882cf06d
parent5ed4790f7555c57fa47e3467c819aa111c632978 (diff)
parentf8e6b44392467bc7a6d6aba8e4f775517d3686ac (diff)
downloadtk-641eafecd32b65ad9d8adfe6803213421a21bef8.zip
tk-641eafecd32b65ad9d8adfe6803213421a21bef8.tar.gz
tk-641eafecd32b65ad9d8adfe6803213421a21bef8.tar.bz2
merge core-8-6-branch
-rw-r--r--.gitignore28
-rw-r--r--generic/tkCanvText.c18
-rw-r--r--generic/ttk/ttkScroll.c9
-rw-r--r--generic/ttk/ttkTreeview.c1
-rw-r--r--library/demos/widget20
-rw-r--r--tests/canvText.test14
-rw-r--r--tests/ttk/entry.test12
-rw-r--r--tests/ttk/treeview.test54
-rw-r--r--unix/tkUnixFont.c64
-rw-r--r--win/tkWinFont.c16
10 files changed, 182 insertions, 54 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d96b03e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+*.a
+*.dll
+*.dylib
+*.exe
+*.exp
+*.lib
+*.o
+*.obj
+*.pdb
+*.res
+*.sl
+*.so
+*/Makefile
+*/config.cache
+*/config.log
+*/config.status
+*/tkConfig.sh
+*/wish*
+*/tktest*
+*/versions.vc
+unix/tk.pc
+unix/tclIndex
+win/Debug*
+win/Release*
+win/*.manifest
+win/nmhlp-out.txt
+win/nmakehlp.out
+
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index cfd0054..1e58ce9 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -957,19 +957,23 @@ DisplayCanvText(
*/
if ((selFirstChar >= 0) && (textPtr->selTextGC != textPtr->gc)) {
- TkDrawAngledTextLayout(display, drawable, textPtr->gc,
- textPtr->textLayout, drawableX, drawableY, textPtr->angle,
- 0, selFirstChar);
+ if (0 < selFirstChar) {
+ TkDrawAngledTextLayout(display, drawable, textPtr->gc,
+ textPtr->textLayout, drawableX, drawableY, textPtr->angle,
+ 0, selFirstChar);
+ }
TkDrawAngledTextLayout(display, drawable, textPtr->selTextGC,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
selFirstChar, selLastChar + 1);
- TkDrawAngledTextLayout(display, drawable, textPtr->gc,
- textPtr->textLayout, drawableX, drawableY, textPtr->angle,
- selLastChar + 1, -1);
+ if (selLastChar + 1 < textPtr->numChars) {
+ TkDrawAngledTextLayout(display, drawable, textPtr->gc,
+ textPtr->textLayout, drawableX, drawableY, textPtr->angle,
+ selLastChar + 1, textPtr->numChars);
+ }
} else {
TkDrawAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
- 0, -1);
+ 0, textPtr->numChars);
}
TkUnderlineAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c
index 47db6ac..9cf8eae 100644
--- a/generic/ttk/ttkScroll.c
+++ b/generic/ttk/ttkScroll.c
@@ -104,15 +104,18 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)
Tcl_Release(corePtr);
if (code != TCL_OK && !Tcl_InterpDeleted(interp)) {
- /* Disable the -scrollcommand, add to stack trace:
+ /* Add error to stack trace.
+ * Also set the SCROLL_UPDATE_REQUIRED flag so that a later call to
+ * TtkScrolled has an effect. Indeed, the error in the -scrollcommand
+ * callback may later be gone, for instance the callback proc got
+ * defined in the meantime.
*/
- ckfree(s->scrollCmd);
- s->scrollCmd = 0;
Tcl_AddErrorInfo(interp, /* @@@ "horizontal" / "vertical" */
"\n (scrolling command executed by ");
Tcl_AddErrorInfo(interp, Tk_PathName(h->corePtr->tkwin));
Tcl_AddErrorInfo(interp, ")");
+ TtkScrollbarUpdateRequired(h);
}
return code;
}
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index ccc5e2e..358e409 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -2842,7 +2842,6 @@ static int TreeviewSeeCommand(
TtkRedisplayWidget(&tv->core);
}
}
- tv->tree.yscroll.total = CountRows(tv->tree.root) - 1;
/* Make sure item is visible:
*/
diff --git a/library/demos/widget b/library/demos/widget
index 6d0b045..fca6cfd 100644
--- a/library/demos/widget
+++ b/library/demos/widget
@@ -83,12 +83,20 @@ image create photo ::img::print -format GIF -data {
# Note that this is run through the message catalog! This is because this is
# actually an image of a word.
-image create photo ::img::new -format GIF -data [mc {
- R0lGODlhHgAOALMPALMAANyIiOu7u8dEROaqqvru7sxVVeGZmbgREfXd3b0iItZ3
- d8IzM9FmZvDMzP///yH5BAEAAA8ALAAAAAAeAA4AAASa8MlJq7046827WVOCHEkw
- nANhUgJlEBIABJIwL3K+4IcUALCHjfbItYZDSgJgkBiYPmBMAUAkkLPKs/BAyLgM
- wAQwOAAY2ByCaw4QAFQSoDEePJ6DmU1xInYZTw5nOEFFdgVUelkVDTIMd3AKFGQ1
- MgI2AwEmQW8APZ0gdRONAks5nhIFVVxdAAkUAS2pAVwFl7ITB4UqHb0XEQA7
+image create photo ::img::new -format PNG -data [mc {
+ iVBORw0KGgoAAAANSUhEUgAAAB4AAAAOCAYAAAA45qw5AAACMElEQVR4AeVTAwxd
+ QRCc2tZHGtQ2w9q2bdsOa9u2bUW1bdt2Z372JZe6DapJLqtb3h7+T8yKi5j4CsYD
+ EUQXxETclT7kWOlH2VV+tFkdQHPSwksSISF+BauCqL0qgOcMWgGfgEkaMsHxqUBk
+ 3plE/sOnh/qDPAPJH/CKFBivGHWzFwBRnHhlqbu1Mh6CoFNnC/JshQ9p4YC2lrKt
+ DCAV+THiVejyhMjAbrNSrroiEfKR9g7ZfCgOog8QfnUQV62wAk68ndQ9ZbyoWO1H
+ Y6eDY1LCQL6a9ApOp9Hi1T0+gQq2JKMlky/oTKQliKWxEZvyG575kpW4pl1aZnQK
+ CLOVt45Lkp8uXp2SL8KO6uitNTZLdpK6s+I/eZbhpmsmWeOGOVQNKYLITzpKPAO3
+ tY7LSNZ7ccSLxX9y3uuOxRkg3dKESMoCHvL+GRVCutXsB3guLgDCeXOv4iWWkvwG
+ BaS+PmlpK6SI9ApI2oC2UtrwZQEkhkH+NtolVlQXJl1I+QltuU3XEc721bIRFpa8
+ IA5iqTo6vNNWmkNBLQbPeXwF2g17Q94nTQAfY3YzeY+WSu8MDzQ2kpELUhSGJUHE
+ 0zeR3rY1L+Xl5G/re+jbiK6KhThwwInsts1fbMUUcpZszKeVtggZEiGdZDe5AtHh
+ 7vL4CGiRvvKPS8FAvq9Nr4ZkFadR2y6kggu1z4vlyIbBp6BugQ8JLEg4bTkD9eMZ
+ QZ8hpJ3VvTtuvbWrY/ElvP/9R+Aj3603+iE3fkEAAAAASUVORK5CYII=
}]
#----------------------------------------------------------------
diff --git a/tests/canvText.test b/tests/canvText.test
index 76903d7..20cbff4 100644
--- a/tests/canvText.test
+++ b/tests/canvText.test
@@ -964,6 +964,20 @@ test canvText-20.1 {angled text bounding box} -setup {
rename transpose {}
} -result {ok ok ok}
+test canvText-20.2 {crash on angled text selection (X11, without xft) - bug 2712f43f6e} -setup {
+ destroy .c
+ canvas .c -background bisque -selectforeground green2
+ grid .c
+ set id [.c create text 50 150 -anchor w -text "Angled text" \
+ -angle 30 -font {Helvetica 32} -fill darkblue]
+} -body {
+ .c select clear
+ .c select from $id 0
+ .c select to $id 8 ; update ; # used to crash on X11 (--disable-xft build only)
+} -cleanup {
+ destroy .c
+} -result {}
+
# cleanup
cleanupTests
return
diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test
index 8b5f490..2e5f43c 100644
--- a/tests/ttk/entry.test
+++ b/tests/ttk/entry.test
@@ -74,6 +74,18 @@ test entry-2.1 "Create entry before scrollbar" -body {
-expand false -fill x
} -cleanup {destroy .te .tsb}
+test entry-2.1.1 "Create entry before scrollbar - scrollbar catches up" -body {
+ pack [ttk::entry .te -xscrollcommand [list .tsb set]] \
+ -expand true -fill both
+ .te insert end [string repeat "abc" 50]
+ catch {update} ; # error triggers because the -xscrollcommand callback
+ # errors out: invalid command name ".tsb"
+ pack [ttk::scrollbar .tsb -orient horizontal -command [list .te xview]] \
+ -expand false -fill x
+ update ; # no error
+ lappend res [expr [lindex [.tsb get] 1] < 1] ; # scrollbar did update
+} -result {1} -cleanup {destroy .te .tsb}
+
test entry-2.2 "Initial scroll position" -body {
ttk::entry .e -font fixed -width 5 -xscrollcommand scroll
.e insert end "0123456789"
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test
index c9dcf52..0ad0443 100644
--- a/tests/ttk/treeview.test
+++ b/tests/ttk/treeview.test
@@ -508,6 +508,60 @@ test treeview-9.1 "scrolling" -setup {
destroy .tree
} -result {I006}
+test treeview-9.2 {scrolling on see command - bug [14188104c3]} -setup {
+ toplevel .top
+ ttk::treeview .top.tree -show {} -height 10 -columns {label} \
+ -yscrollcommand [list .top.vs set]
+ ttk::scrollbar .top.vs -command {.top.tree yview}
+ grid .top.tree -row 0 -column 0 -sticky ns
+ grid .top.vs -row 0 -column 1 -sticky ns
+ update
+ proc setrows {n} {
+ .top.tree delete [.top.tree children {}]
+ for {set i 1} {$i <= $n} {incr i} {
+ .top.tree insert {} end -id row$i \
+ -values [list [format "Row %2.2d" $i]]
+ }
+ .top.tree see row1
+ update idletasks
+ }
+} -body {
+ setrows 10
+ set res [.top.vs get]
+ setrows 20
+ lappend res [expr [lindex [.top.vs get] 1] < 1]
+} -cleanup {
+ destroy .top
+} -result {0.0 1.0 1}
+
+test treeview-9.3 {scrolling on see command, requested item is closed} -setup {
+ toplevel .top
+ ttk::treeview .top.tree -show tree -height 10 -columns {label} \
+ -yscrollcommand [list .top.vs set]
+ ttk::scrollbar .top.vs -command {.top.tree yview}
+ grid .top.tree -row 0 -column 0 -sticky ns
+ grid .top.vs -row 0 -column 1 -sticky ns
+
+ .top.tree insert {} end -id a -text a
+ .top.tree insert a end -id b -text b
+ .top.tree insert b end -id c -text c
+ .top.tree insert c end -id d -text d
+ .top.tree insert d end -id e -text e
+ for {set i 6} {$i <= 15} {incr i} {
+ .top.tree insert {} end -id row$i \
+ -values [list [format "Row %2.2d" $i]]
+ }
+ update
+} -body {
+ set before [lindex [.top.vs get] 1]
+ .top.tree see e
+ update idletasks
+ set after [lindex [.top.vs get] 1]
+ expr $after < $before
+} -cleanup {
+ destroy .top
+} -result {1}
+
### identify tests:
#
proc identify* {tv comps args} {
diff --git a/unix/tkUnixFont.c b/unix/tkUnixFont.c
index c91da55..0963953 100644
--- a/unix/tkUnixFont.c
+++ b/unix/tkUnixFont.c
@@ -3098,29 +3098,31 @@ GetImageOfText(
Pixmap bitmap;
GC bitmapGC;
XGCValues values;
- XImage *image;
+ XImage *image = NULL;
(void) Tk_MeasureChars(tkfont, source, numBytes, -1, 0, &width);
height = fontPtr->fm.ascent + fontPtr->fm.descent;
- bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
- values.graphics_exposures = False;
- values.foreground = BlackPixel(display, DefaultScreen(display));
- bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
- &values);
- XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
-
- values.font = Tk_FontId(tkfont);
- values.foreground = WhitePixel(display, DefaultScreen(display));
- values.background = BlackPixel(display, DefaultScreen(display));
- XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
- Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
- fontPtr->fm.ascent);
- XFreeGC(display, bitmapGC);
-
- image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
- ZPixmap);
- Tk_FreePixmap(display, bitmap);
+ if ((width > 0) && (height > 0)) {
+ bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+ values.graphics_exposures = False;
+ values.foreground = BlackPixel(display, DefaultScreen(display));
+ bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+ &values);
+ XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+
+ values.font = Tk_FontId(tkfont);
+ values.foreground = WhitePixel(display, DefaultScreen(display));
+ values.background = BlackPixel(display, DefaultScreen(display));
+ XChangeGC(display, bitmapGC, GCFont|GCForeground|GCBackground, &values);
+ Tk_DrawChars(display, bitmap, bitmapGC, tkfont, source, numBytes, 0,
+ fontPtr->fm.ascent);
+ XFreeGC(display, bitmapGC);
+
+ image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ Tk_FreePixmap(display, bitmap);
+ }
*realWidthPtr = width;
*realHeightPtr = height;
@@ -3135,21 +3137,23 @@ InitDestImage(
int height,
Pixmap *bitmapPtr)
{
- Pixmap bitmap;
- XImage *image;
+ Pixmap bitmap = None;
+ XImage *image = NULL;
GC bitmapGC;
XGCValues values;
- bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
- values.graphics_exposures = False;
- values.foreground = BlackPixel(display, DefaultScreen(display));
- bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
- &values);
- XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
- XFreeGC(display, bitmapGC);
+ if ((width > 0) && (height > 0)) {
+ bitmap = Tk_GetPixmap(display, drawable, width, height, 1);
+ values.graphics_exposures = False;
+ values.foreground = BlackPixel(display, DefaultScreen(display));
+ bitmapGC = XCreateGC(display, bitmap, GCGraphicsExposures|GCForeground,
+ &values);
+ XFillRectangle(display, bitmap, bitmapGC, 0, 0, width, height);
+ XFreeGC(display, bitmapGC);
- image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
- ZPixmap);
+ image = XGetImage(display, bitmap, 0, 0, width, height, AllPlanes,
+ ZPixmap);
+ }
*bitmapPtr = bitmap;
return image;
}
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index 91f8f14..3d38ea4 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -215,8 +215,8 @@ static int LoadFontRanges(HDC hdc, HFONT hFont,
USHORT **startCount, USHORT **endCount,
int *symbolPtr);
static void MultiFontTextOut(HDC hdc, WinFont *fontPtr,
- const char *source, int numBytes, int x, int y,
- double angle);
+ const char *source, int numBytes,
+ double x, double y, double angle);
static void ReleaseFont(WinFont *fontPtr);
static inline void ReleaseSubFont(SubFont *subFontPtr);
static int SeenName(const char *name, Tcl_DString *dsPtr);
@@ -1294,11 +1294,11 @@ TkDrawAngledChars(
*/
PatBlt(dcMem, 0, 0, size.cx, size.cy, BLACKNESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0xEA02E9);
PatBlt(dcMem, 0, 0, size.cx, size.cy, WHITENESS);
- MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
BitBlt(dc, (int)x, (int)y - tm.tmAscent, size.cx, size.cy, dcMem,
0, 0, 0x8A0E06);
@@ -1315,7 +1315,7 @@ TkDrawAngledChars(
SetTextAlign(dc, TA_LEFT | TA_BASELINE);
SetTextColor(dc, gc->foreground);
SetBkMode(dc, TRANSPARENT);
- MultiFontTextOut(dc, fontPtr, source, numBytes, (int)x, (int)y, angle);
+ MultiFontTextOut(dc, fontPtr, source, numBytes, x, y, angle);
} else {
HBITMAP oldBitmap, bitmap;
HDC dcMem;
@@ -1460,7 +1460,7 @@ MultiFontTextOut(
* following string. */
const char *source, /* Potentially multilingual UTF-8 string. */
int numBytes, /* Length of string in bytes. */
- int x, int y, /* Coordinates at which to place origin of
+ double x, double y, /* Coordinates at which to place origin of
* string when drawing. */
double angle)
{
@@ -1472,6 +1472,7 @@ MultiFontTextOut(
const char *p, *end, *next;
SubFont *lastSubFontPtr, *thisSubFontPtr;
TEXTMETRICW tm;
+ double sinA = sin(angle * PI/180.0), cosA = cos(angle * PI/180.0);
lastSubFontPtr = &fontPtr->subFontArray[0];
oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle);
@@ -1501,7 +1502,8 @@ MultiFontTextOut(
(WCHAR *)Tcl_DStringValue(&runString),
Tcl_DStringLength(&runString) >> familyPtr->isWideFont,
&size);
- x += size.cx;
+ x += cosA*size.cx;
+ y -= sinA*size.cx;
Tcl_DStringFree(&runString);
}
lastSubFontPtr = thisSubFontPtr;