summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2024-08-09 08:00:59 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2024-08-09 08:00:59 (GMT)
commit54d140d9584a12bdee6df2bb413009375ac6c551 (patch)
tree267fd4086f041e990610639661661141ffa0d428
parentc6075d165e265b09651f8b3988e6487e510b42cd (diff)
parente91788c4e7315e3032fe2fb1442ce807ad7323ee (diff)
downloadtk-54d140d9584a12bdee6df2bb413009375ac6c551.zip
tk-54d140d9584a12bdee6df2bb413009375ac6c551.tar.gz
tk-54d140d9584a12bdee6df2bb413009375ac6c551.tar.bz2
Fix [26b2825319]: Strange behavior for highlightthickness/insertwidth/insertborderwidth in entry/spinbox
-rw-r--r--doc/3DBorder.32
-rw-r--r--generic/tkEntry.c23
-rw-r--r--macosx/tkMacOSXDraw.c23
3 files changed, 25 insertions, 23 deletions
diff --git a/doc/3DBorder.3 b/doc/3DBorder.3
index d609d6d..0233f94 100644
--- a/doc/3DBorder.3
+++ b/doc/3DBorder.3
@@ -185,7 +185,7 @@ compile time.
a widget to indicate that it has received the input focus.
On the Macintosh, this puts a 1 pixel border in the bgGC color between
the widget and the focus ring, except in the case where highlightWidth
-is 1, in which case the border is left out.
+is 0 or 1, in which case the border is left out.
For proper Mac L&F, use highlightWidth of 3.
.PP
\fBTk_Get3DBorder\fR is identical to \fBTk_Alloc3DBorderFromObj\fR except
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index ab24cf8..1077d55 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -1190,11 +1190,14 @@ ConfigureEntry(
}
Tk_SetBackgroundFromBorder(entryPtr->tkwin, border);
- if (entryPtr->insertWidth <= 0) {
- entryPtr->insertWidth = 2;
+ if (entryPtr->insertWidth < 0) {
+ entryPtr->insertWidth = 0;
}
- if (entryPtr->insertBorderWidth > entryPtr->insertWidth/2) {
- entryPtr->insertBorderWidth = entryPtr->insertWidth/2;
+ if (entryPtr->insertBorderWidth < 0) {
+ entryPtr->insertBorderWidth = 0;
+ }
+ if (entryPtr->highlightWidth < 0) {
+ entryPtr->highlightWidth = 0;
}
if (entryPtr->type == TK_SPINBOX) {
@@ -1316,9 +1319,6 @@ ConfigureEntry(
Tk_SetInternalBorder(entryPtr->tkwin,
entryPtr->borderWidth + entryPtr->highlightWidth);
- if (entryPtr->highlightWidth < 0) {
- entryPtr->highlightWidth = 0;
- }
entryPtr->inset = entryPtr->highlightWidth
+ entryPtr->borderWidth + XPAD;
break;
@@ -1746,14 +1746,19 @@ DisplayEntry(
Tk_CharBbox(entryPtr->textLayout, entryPtr->insertPos, &cursorX, NULL,
NULL, NULL);
cursorX += entryPtr->layoutX;
- cursorX -= (entryPtr->insertWidth == 1) ? 1 : (entryPtr->insertWidth)/2;
+ cursorX -= (entryPtr->insertWidth <= 1) ? 1 : (entryPtr->insertWidth)/2;
Tk_SetCaretPos(entryPtr->tkwin, cursorX, baseY - fm.ascent,
fm.ascent + fm.descent);
if ((entryPtr->insertPos >= entryPtr->leftIndex) && cursorX < xBound) {
if (entryPtr->flags & CURSOR_ON) {
+ /* Take minimum of given insertBorderWidth and insertWidth/2 */
+ int insertBorderWidth = entryPtr->insertWidth/2;
+ if (entryPtr->insertBorderWidth < insertBorderWidth) {
+ insertBorderWidth = entryPtr->insertBorderWidth;
+ }
Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder,
cursorX, baseY - fm.ascent, entryPtr->insertWidth,
- fm.ascent + fm.descent, entryPtr->insertBorderWidth,
+ fm.ascent + fm.descent, insertBorderWidth,
TK_RELIEF_RAISED);
} else if (entryPtr->insertBorder == entryPtr->selBorder) {
Tk_Fill3DRectangle(tkwin, pixmap, border, cursorX,
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 8ebdde4..0cb475d 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -264,8 +264,7 @@ Tk_MacOSXGetCGContextForDrawable(
colorspace = CGColorSpaceCreateDeviceRGB();
bitmapInfo |= kCGImageAlphaPremultipliedFirst;
}
- macDraw->context = CGBitmapContextCreate(NULL,
- (unsigned)macDraw->size.width,
+ macDraw->context = CGBitmapContextCreate(NULL, (unsigned)macDraw->size.width,
(unsigned)macDraw->size.height, bitsPerComponent, 0,
colorspace, bitmapInfo);
if (macDraw->context) {
@@ -1447,8 +1446,6 @@ end:
dc.clipRgn = NULL;
}
*dcPtr = dc;
- // The goal is to allow immediate drawing; canDraw == 0 should happen far less often.
- if (0) fprintf(stderr, "tkmacosxsdc canDraw %d\n", canDraw);
return canDraw;
}
@@ -1551,9 +1548,9 @@ TkMacOSXGetClipRgn(
* Tk_ClipDrawableToRect --
*
* Clip all drawing into the drawable d to the given rectangle. If width
- * or height are negative, reset to no clipping.bThis is called by the
- * Text widget to display each DLine, and by the Canvas widget when it
- * is updating a sub rectangle in the canvas.
+ * or height are negative, reset to no clipping. This is called by the
+ * Text widget to display each DLine, and by the Canvas widget when it
+ * is updating a sub rectangle in the canvas.
*
* Results:
* None.
@@ -1676,7 +1673,7 @@ TkMacOSXMakeStippleMap(
*
* On the Macintosh, this puts a 1 pixel border in the bgGC color between
* the widget and the focus ring, except in the case where highlightWidth
- * is 1, in which case the border is left out.
+ * is 0 or 1, in which case the border is left out.
*
* For proper Mac L&F, use highlightWidth of 3.
*
@@ -1691,19 +1688,19 @@ TkMacOSXMakeStippleMap(
*/
void
-Tk_DrawHighlightBorder (
+Tk_DrawHighlightBorder(
Tk_Window tkwin,
GC fgGC,
GC bgGC,
int highlightWidth,
Drawable drawable)
{
- if (highlightWidth == 1) {
- TkDrawInsetFocusHighlight (tkwin, fgGC, highlightWidth, drawable, 0);
+ if (highlightWidth <= 1) {
+ TkDrawInsetFocusHighlight(tkwin, fgGC, 1, drawable, 0);
} else {
- TkDrawInsetFocusHighlight (tkwin, bgGC, highlightWidth, drawable, 0);
+ TkDrawInsetFocusHighlight(tkwin, bgGC, highlightWidth, drawable, 0);
if (fgGC != bgGC) {
- TkDrawInsetFocusHighlight (tkwin, fgGC, highlightWidth - 1,
+ TkDrawInsetFocusHighlight(tkwin, fgGC, highlightWidth - 1,
drawable, 0);
}
}