diff options
author | kevin_walzer <kevin_walzer@noemail.net> | 2015-02-12 15:30:59 (GMT) |
---|---|---|
committer | kevin_walzer <kevin_walzer@noemail.net> | 2015-02-12 15:30:59 (GMT) |
commit | 59508bbff8f6075ffdadfea10c64b605fa8fc17d (patch) | |
tree | 57bfcd9849ea746b94f894444be4b6ad72e58f6f /macosx | |
parent | 1a031f4a6d05b30227247ea9592e3dc71c2da069 (diff) | |
download | tk-59508bbff8f6075ffdadfea10c64b605fa8fc17d.zip tk-59508bbff8f6075ffdadfea10c64b605fa8fc17d.tar.gz tk-59508bbff8f6075ffdadfea10c64b605fa8fc17d.tar.bz2 |
Cleaner implementation of metrics for radiobuttons and checkbuttons under Cocoa; still a bit of extra padding required, but only when absolutely necessary
FossilOrigin-Name: 31b514d390fce88a087c43ff1df9c88df6f86995
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXButton.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 51656ee..d676641 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, @@ -397,13 +379,34 @@ TkpComputeButtonGeometry( 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 to ensure image does not draw right over + radiobutton on left.*/ + if (butPtr->image != None) { + width += 50; + } else if (butPtr->bitmap != None) { + width +=50; + } else { + /*If just text, just add width of string.*/ + width += txtWidth; + } break; case TYPE_CHECK_BUTTON: - width += 50; + /*No padding required here.*/ + if (butPtr->image != None) { + width += 0; + } else if (butPtr->bitmap != None) { + width +=0; + } else { + /*If just text, just add width of string.*/ + width += txtWidth; + } break; } @@ -417,6 +420,7 @@ TkpComputeButtonGeometry( butPtr->inset = 0; butPtr->inset += butPtr->highlightWidth; + if (TkMacOSXComputeButtonDrawParams(butPtr,&drawParams)) { @@ -471,6 +475,7 @@ TkpComputeButtonGeometry( } /* +/* *---------------------------------------------------------------------- * * DrawButtonImageAndText -- |