From c41c244e7701ad4fb83800220a56e05b9bd5e645 Mon Sep 17 00:00:00 2001 From: csaba Date: Wed, 25 Jan 2023 18:18:59 +0000 Subject: Improvements related to the geometry of the checkbutton and radiobutton indicator images --- unix/tkUnixButton.c | 52 +++++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 64d11cb..0e1a3fb 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -328,7 +328,7 @@ TkpDrawCheckIndicator( * Adjust the image's coordinates in the drawable and display the image */ - x -= dim/2; x -= 2; + x -= dim/2; y -= dim/2; Tk_RedrawImage(img, 0, 0, dim, dim, d, x, y); Tk_FreeImage(img); @@ -709,38 +709,24 @@ TkpDisplayButton( * x and y refer to the top-left corner of the text or image or bitmap. */ - if ((butPtr->type == TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { - if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) { - TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; - XColor *selColor = NULL; + if ((butPtr->type == TYPE_CHECK_BUTTON || butPtr->type == TYPE_RADIO_BUTTON) + && butPtr->indicatorOn + && butPtr->indicatorDiameter > 2*butPtr->borderWidth) { + TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; + XColor *selColor = NULL; + int btype = (butPtr->type == TYPE_CHECK_BUTTON ? + CHECK_BUTTON : RADIO_BUTTON); - if (selBorder != NULL) { - selColor = selBorder->bgColorPtr; - } - x -= butPtr->indicatorSpace/2; - y = Tk_Height(tkwin)/2; - TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y, - border, butPtr->normalFg, selColor, butPtr->disabledFg, - ((butPtr->flags & SELECTED) ? 1 : - (butPtr->flags & TRISTATED) ? 2 : 0), - (butPtr->state == STATE_DISABLED), CHECK_BUTTON); - } - } else if ((butPtr->type == TYPE_RADIO_BUTTON) && butPtr->indicatorOn) { - if (butPtr->indicatorDiameter > 2*butPtr->borderWidth) { - TkBorder *selBorder = (TkBorder *) butPtr->selectBorder; - XColor *selColor = NULL; - - if (selBorder != NULL) { - selColor = selBorder->bgColorPtr; - } - x -= butPtr->indicatorSpace/2; - y = Tk_Height(tkwin)/2; - TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y, - border, butPtr->normalFg, selColor, butPtr->disabledFg, - ((butPtr->flags & SELECTED) ? 1 : - (butPtr->flags & TRISTATED) ? 2 : 0), - (butPtr->state == STATE_DISABLED), RADIO_BUTTON); + if (selBorder != NULL) { + selColor = selBorder->bgColorPtr; } + x -= butPtr->indicatorSpace/2; + y = Tk_Height(tkwin)/2; + TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y, + border, butPtr->normalFg, selColor, butPtr->disabledFg, + ((butPtr->flags & SELECTED) ? 1 : + (butPtr->flags & TRISTATED) ? 2 : 0), + (butPtr->state == STATE_DISABLED), btype); } /* @@ -1012,10 +998,6 @@ TkpComputeButtonGeometry( } if ((butPtr->type >= TYPE_CHECK_BUTTON) && butPtr->indicatorOn) { butPtr->indicatorDiameter = fm.linespace; - if (butPtr->type == TYPE_CHECK_BUTTON) { - butPtr->indicatorDiameter = - (80*butPtr->indicatorDiameter)/100; - } butPtr->indicatorSpace = butPtr->indicatorDiameter + avgWidth; } } -- cgit v0.12