diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-10 20:10:22 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2024-06-10 20:10:22 (GMT) |
commit | 2bc6576988e60413ca7873f9c9899f9f1f012564 (patch) | |
tree | c41e59c93f104338f9529db07105ceb8a246bd75 /generic/tkMessage.c | |
parent | 6800a25eec9c9dfcd3640892d0a5a3d73e7409e7 (diff) | |
download | tk-2bc6576988e60413ca7873f9c9899f9f1f012564.zip tk-2bc6576988e60413ca7873f9c9899f9f1f012564.tar.gz tk-2bc6576988e60413ca7873f9c9899f9f1f012564.tar.bz2 |
Better solution for [4d0a6f32b7], which doesn't cache padX/padY/borderWidth/hightlightWidth any more: If scaling changes, it needs to be re-calculated, which wasn't taken into account. Done for 'button' and 'message'
Diffstat (limited to 'generic/tkMessage.c')
-rw-r--r-- | generic/tkMessage.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 07dad51..05c0c66 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -505,6 +505,11 @@ ConfigureMessage( if (msgPtr->highlightWidth < 0) { msgPtr->highlightWidth = 0; + if (msgPtr->highlightWidth) { + Tcl_DecrRefCount(msgPtr->highlightWidthObj); + } + msgPtr->highlightWidthObj = Tcl_NewIntObj(0); + Tcl_IncrRefCount(msgPtr->highlightWidthObj); } Tk_FreeSavedOptions(&savedOptions); @@ -552,10 +557,22 @@ MessageWorldChanged( msgPtr->textGC = gc; Tk_GetFontMetrics(msgPtr->tkfont, &fm); + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXPtr, &msgPtr->padX); if (msgPtr->padX < 0) { + if (strcmp(Tcl_GetString(msgPtr->padXPtr), "-1")) { + Tcl_DecrRefCount(msgPtr->padXPtr); + msgPtr->padXPtr = Tcl_NewIntObj(-1); + Tcl_IncrRefCount(msgPtr->padXPtr); + } msgPtr->padX = fm.ascent / 2; } + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYPtr, &msgPtr->padY); if (msgPtr->padY < 0) { + if (strcmp(Tcl_GetString(msgPtr->padYPtr), "-1")) { + Tcl_DecrRefCount(msgPtr->padYPtr); + msgPtr->padYPtr = Tcl_NewIntObj(-1); + Tcl_IncrRefCount(msgPtr->padYPtr); + } msgPtr->padY = fm.ascent / 4; } @@ -600,6 +617,9 @@ ComputeMessageGeometry( Tk_FreeTextLayout(msgPtr->textLayout); + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &msgPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &msgPtr->highlightWidth); + inset = msgPtr->borderWidth + msgPtr->highlightWidth; /* @@ -679,8 +699,12 @@ DisplayMessage( Message *msgPtr = (Message *)clientData; Tk_Window tkwin = msgPtr->tkwin; int x, y; - int borderWidth = msgPtr->highlightWidth; + int borderWidth; + + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &msgPtr->borderWidth); + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &msgPtr->highlightWidth); + borderWidth = msgPtr->highlightWidth; msgPtr->flags &= ~REDRAW_PENDING; if ((msgPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; @@ -762,6 +786,7 @@ MessageEventProc( } else if (eventPtr->type == FocusIn) { if (eventPtr->xfocus.detail != NotifyInferior) { msgPtr->flags |= GOT_FOCUS; + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &msgPtr->highlightWidth); if (msgPtr->highlightWidth > 0) { goto redraw; } @@ -769,6 +794,7 @@ MessageEventProc( } else if (eventPtr->type == FocusOut) { if (eventPtr->xfocus.detail != NotifyInferior) { msgPtr->flags &= ~GOT_FOCUS; + Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &msgPtr->highlightWidth); if (msgPtr->highlightWidth > 0) { goto redraw; } |