summaryrefslogtreecommitdiffstats
path: root/generic/tkListbox.c
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2016-01-16 14:16:00 (GMT)
committerfvogel <fvogelnew1@free.fr>2016-01-16 14:16:00 (GMT)
commitd48a10cb3142cfbefd0314439d877da5eb03b926 (patch)
tree053c4cf036feedfa853b32d1faa32d48a19a6e8e /generic/tkListbox.c
parentcc44a614a3a33b8007a980a64270832c67c629f2 (diff)
downloadtk-d48a10cb3142cfbefd0314439d877da5eb03b926.zip
tk-d48a10cb3142cfbefd0314439d877da5eb03b926.tar.gz
tk-d48a10cb3142cfbefd0314439d877da5eb03b926.tar.bz2
Addressed issue A and question 6 (see artifact [9d48a9c212] of ticket [3f456a5bb9]).
Issue A is fixed. Test case: package req Tk listbox .l .l insert end M M M M M M M M M pack .l .l conf -just center ; # or right .l conf -highlightthickness 40 .l selection set 4 Regarding question 6, Tk_TextWidth is a bit lower level function in the API, which must be slightly beneficial regarding performance. Tk_TextWidth is therefore preferred.
Diffstat (limited to 'generic/tkListbox.c')
-rw-r--r--generic/tkListbox.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index 56e2c2f..a57650b 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -1857,7 +1857,7 @@ DisplayListbox(
* or right edge of the listbox is
* off-screen. */
Pixmap pixmap;
- int totalLength, height;
+ int textWidth;
listPtr->flags &= ~REDRAW_PENDING;
if (listPtr->flags & LISTBOX_DELETED) {
@@ -2079,21 +2079,19 @@ DisplayListbox(
Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
- Tk_ComputeTextLayout(listPtr->tkfont, stringRep, stringLen, 0,
- listPtr->justify, TK_IGNORE_NEWLINES, &totalLength, &height);
+ textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
Tk_GetFontMetrics(listPtr->tkfont, &fm);
y += fm.ascent + listPtr->selBorderWidth;
if (listPtr->justify == TK_JUSTIFY_LEFT) {
- x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
+ x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
} else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
- x = width - totalLength - listPtr->inset -
- listPtr->selBorderWidth - listPtr->xOffset +
- GetMaxOffset(listPtr) - 1;
+ x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth)
+ - textWidth - listPtr->xOffset + GetMaxOffset(listPtr);
} else {
- x = (width + GetMaxOffset(listPtr))/2 - totalLength/2 -
- listPtr->xOffset;
+ x = (Tk_Width(tkwin) - textWidth)/2
+ - listPtr->xOffset + GetMaxOffset(listPtr)/2;
}
Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont,