Tk Source Code

Artifact [bad41fb8]
Login

Artifact bad41fb8a34c1ee85cd024be70e5928a63462d2bc13bc18bbb961a1d0f141152:

Attachment "efbedd5ff5.diff" to ticket [efbedd5f] added by chrstphrchvz 2020-03-30 05:48:15.
diff --git macosx/tkMacOSXButton.c macosx/tkMacOSXButton.c
index 8a121eecc..c7ff5987f 100644
--- macosx/tkMacOSXButton.c
+++ macosx/tkMacOSXButton.c
@@ -332,39 +332,40 @@ TkpComputeButtonGeometry(
 	haveText = 1;
     }
 
-    if (haveImage && haveText) { /* Image and Text */
-	switch ((enum compound) butPtr->compound) {
-	case COMPOUND_TOP:
-	case COMPOUND_BOTTOM:
-	    /*
-	     * Image is above or below text.
-	     */
-
-	    height += txtHeight + butPtr->padY;
-	    width = (width > txtWidth ? width : txtWidth);
-	    break;
-	case COMPOUND_LEFT:
-	case COMPOUND_RIGHT:
-	    /*
-	     * Image is left or right of text.
-	     */
-
-	    width += txtWidth + 2*butPtr->padX;
-	    height = (height > txtHeight ? height : txtHeight);
-	    break;
-	case COMPOUND_CENTER:
-	    /*
-	     * Image and text are superimposed.
-	     */
+    if (haveImage) {
+	if (haveText) { /* Image and Text */
+	    switch ((enum compound) butPtr->compound) {
+	    case COMPOUND_TOP:
+	    case COMPOUND_BOTTOM:
+		/*
+		* Image is above or below text.
+		*/
+
+		height += txtHeight + butPtr->padY;
+		width = (width > txtWidth ? width : txtWidth);
+		break;
+	    case COMPOUND_LEFT:
+	    case COMPOUND_RIGHT:
+		/*
+		* Image is left or right of text.
+		*/
+
+		width += txtWidth + 2*butPtr->padX;
+		height = (height > txtHeight ? height : txtHeight);
+		break;
+	    case COMPOUND_CENTER:
+		/*
+		* Image and text are superimposed.
+		*/
 
-	    width = (width > txtWidth ? width : txtWidth);
-	    height = (height > txtHeight ? height : txtHeight);
-	    break;
-	default:
-	    break;
+		width = (width > txtWidth ? width : txtWidth);
+		height = (height > txtHeight ? height : txtHeight);
+		break;
+	    default:
+		break;
+	    }
 	}
-	width += butPtr->indicatorSpace;
-    } else if (haveImage) { /* Image only */
+	/* Image with or without text */
 	width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace;
 	height = butPtr->height > 0 ? butPtr->height : height;
 	if (butPtr->type == TYPE_BUTTON) {
@@ -481,7 +482,7 @@ DrawButtonImageAndText(
     }
 
     haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
-    if (haveImage && haveText) { /* Image and Text */
+    if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { /* Image and Text */
         int x, y;
 
         switch ((enum compound) butPtr->compound) {