diff options
author | dgp <dgp@users.sourceforge.net> | 2015-02-12 17:50:17 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-02-12 17:50:17 (GMT) |
commit | 436d703a7691d7b1af382e9891e1c8eed13bceb4 (patch) | |
tree | ea36511e6ebe1c879d7b2e74c23da57bdd18dc55 | |
parent | 0f8433166f0f08199aa9feef883201a625281606 (diff) | |
parent | 7b2a9f3e0e3a52a26c1fcb28818f8b0a988ce5b3 (diff) | |
download | tk-436d703a7691d7b1af382e9891e1c8eed13bceb4.zip tk-436d703a7691d7b1af382e9891e1c8eed13bceb4.tar.gz tk-436d703a7691d7b1af382e9891e1c8eed13bceb4.tar.bz2 |
merge 8.5
-rw-r--r-- | macosx/tkMacOSXButton.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 763f544..4dddcf9 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -296,24 +296,6 @@ TkpComputeButtonGeometry( haveImage = 1; } - /*Tk Aqua can't handle metrics for radiobuttons and checkbuttons with images unless they are set first. These are derived from experimentation.*/ - if (haveImage && !haveText) { - switch (butPtr->type) { - case TYPE_RADIO_BUTTON: - width = butPtr->width; - width +=50; - break; - case TYPE_CHECK_BUTTON: - width = butPtr->width; - width +=50; - break; - case TYPE_BUTTON: - width = butPtr->width; - width += 0; - break; - } - } - if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, @@ -396,14 +378,51 @@ TkpComputeButtonGeometry( width += 2 * butPtr->padX; height += 2 * butPtr->padY; - - /* Need special handling for radiobuttons and checkbuttons: the text is drawn right on top of the button unless we expand the width. This is not perfect; some radiobuttons may render on top anyway. Need to find a better solution to calculate average text width.*/ + /* Need special handling for radiobuttons and checkbuttons: + the text and images is drawn right on top of the button unless + we expand the width. This is not perfect; some radiobuttons may render + on top anyway. + */ switch (butPtr->type) { case TYPE_RADIO_BUTTON: - width += 50; + /*Pad radiobutton by 50 if indicatorOn to ensure image does not draw + right over radiobutton on left.*/ + if (butPtr->image != None) { + if (butPtr->indicatorOn) { + width += 50; + } else { + width += 0; + } + } else if (butPtr->bitmap != None) { + if (butPtr->indicatorOn) { + width += 50; + } else { + width += 0; + } + } else { + /*If just text, just add width of string.*/ + width += txtWidth; + } break; case TYPE_CHECK_BUTTON: - width += 50; + /*Pad checkbutton by 50 if indicatorOn to ensure image does not draw + right over radiobutton on left.*/ + if (butPtr->image != None) { + if (butPtr->indicatorOn) { + width += 50; + } else { + width += 0; + } + } else if (butPtr->bitmap != None) { + if (butPtr->indicatorOn) { + width += 50; + } else { + width += 0; + } + } else { + /*If just text, just add width of string.*/ + width += txtWidth; + } break; } |