summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2018-11-20 19:38:45 (GMT)
committerculler <culler>2018-11-20 19:38:45 (GMT)
commit45ed0ac3a06b97229909bda4c11cade4881adfb6 (patch)
tree909c4a932cb4a4d3290fd9bb7a48b92db7bd7153
parente4751d7d4f8a5cee26fbfd2b0c45f7515f4d3d05 (diff)
parent804b2865d43d53651eda82e4698ac6e44ee0af37 (diff)
downloadtk-45ed0ac3a06b97229909bda4c11cade4881adfb6.zip
tk-45ed0ac3a06b97229909bda4c11cade4881adfb6.tar.gz
tk-45ed0ac3a06b97229909bda4c11cade4881adfb6.tar.bz2
Fix the bug that caused a Spinbox to shrink each time it was displayed on macOS.
-rw-r--r--macosx/tkMacOSXEntry.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c
index ab236c6..dfb9eb1 100644
--- a/macosx/tkMacOSXEntry.c
+++ b/macosx/tkMacOSXEntry.c
@@ -91,7 +91,7 @@ TkpDrawEntryBorderAndFocus(
TkMacOSXDrawingContext dc;
GC bgGC;
Tk_Window tkwin = entryPtr->tkwin;
- int oldWidth = 0;
+ int oldWidth;
MacDrawable *macDraw = (MacDrawable *) d;
const HIThemeFrameDrawInfo info = {
.version = 0,
@@ -123,8 +123,14 @@ TkpDrawEntryBorderAndFocus(
if (isSpinbox) {
int incDecWidth;
- oldWidth = Tk_Width(tkwin);
+ /*
+ * Temporarily change the width of the widget so that the same code can
+ * be used for drawing the Entry portion of the Spinbox as is used to
+ * draw an ordinary Entry. The width must be restored before
+ * returning.
+ */
+ oldWidth = Tk_Width(tkwin);
ComputeIncDecParameters(Tk_Height(tkwin) - 2 * MAC_OSX_FOCUS_WIDTH,
&incDecWidth);
Tk_Width(tkwin) -= incDecWidth + 1;
@@ -149,6 +155,15 @@ TkpDrawEntryBorderAndFocus(
bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH;
if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) {
+
+ /*
+ * No graphics context is available. If the widget is a Spinbox, we
+ * must restore its width before returning 0. (Ticket [273b6a4996].)
+ */
+
+ if (isSpinbox) {
+ Tk_Width(tkwin) = oldWidth;
+ }
return 0;
}
ChkErr(HIThemeDrawFrame, &bounds, &info, dc.context, HIOrientation);