From d79a6c14c3ddf275b5ce4a4fec79ecd942b450c0 Mon Sep 17 00:00:00 2001 From: "drh@sqlite.org" Date: Wed, 28 Aug 2002 01:08:06 +0000 Subject: Fix for bug #582457: make radio and checkbuttons work like Windows when -relief is sunken, -offrelief is flat, and -overrelief is raised. --- ChangeLog | 8 ++++++++ doc/checkbutton.n | 10 ++++++++-- doc/radiobutton.n | 11 +++++++++-- mac/tkMacButton.c | 9 ++++++--- unix/tkUnixButton.c | 35 +++++++++++++++++++++++++++++++---- win/tkWinButton.c | 35 +++++++++++++++++++++++++++++++---- 6 files changed, 93 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index b56c485..6781dda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-08-27 D. Richard Hipp + + * doc/checkbutton.n: [Bug 582457] Fix the -offrelief option so + * doc/radiobutton.n: that when -offrelief is flat and -relief is + * mac/tkMacButton.c: sunken and -overrelief is raised, buttons + * unix/tkUnixButton.c: work look toolbar buttons under Windows. + * win/tkWinButton.c: See also: TIP #82. + 2002-08-26 Don Porter * win/Makefile.in: Removed dependence on the (parts of) the diff --git a/doc/checkbutton.n b/doc/checkbutton.n index 9f762bd..9e83699 100644 --- a/doc/checkbutton.n +++ b/doc/checkbutton.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: checkbutton.n,v 1.5 2002/06/17 10:54:29 drh Exp $ +'\" RCS: @(#) $Id: checkbutton.n,v 1.6 2002/08/28 01:08:06 drh Exp $ '\" .so man.macros .TH checkbutton n 4.4 Tk "Tk Built-In Commands" @@ -46,7 +46,13 @@ selected and raised otherwise. .VS 8.4 .OP \-offrelief offRelief OffRelief Specifies the relief for the checkbutton when the indicator is not drawn and -the checkbutton is off. The default value is "raised". +the checkbutton is off. The default value is "raised". By setting this option +to "flat" and setting -indicatoron to false and -overrelief to raised, +the effect is achieved +of having a flat button that raises on mouse-over and which is +depressed when activated. This is the behavior typically exhibited by +the Bold, Italic, and Underline checkbuttons on the toolbar of a +word-processor, for example. .VE 8.4 .OP \-offvalue offValue Value Specifies value to store in the button's associated variable whenever diff --git a/doc/radiobutton.n b/doc/radiobutton.n index 5c3b17a..2cc08e2 100644 --- a/doc/radiobutton.n +++ b/doc/radiobutton.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: radiobutton.n,v 1.5 2002/06/17 10:54:29 drh Exp $ +'\" RCS: @(#) $Id: radiobutton.n,v 1.6 2002/08/28 01:08:06 drh Exp $ '\" .so man.macros .TH radiobutton n 4.4 Tk "Tk Built-In Commands" @@ -56,7 +56,14 @@ displaying when the widget is selected. .VS 8.4 .OP \-offrelief offRelief OffRelief Specifies the relief for the checkbutton when the indicator is not drawn and -the checkbutton is off. The default value is "raised". +the checkbutton is off. The default value is "raised". By setting this option +to "flat" and setting -indicatoron to false and -overrelief to raised, +the effect is achieved +of having a flat button that raises on mouse-over and which is +depressed when activated. This is the behavior typically exhibited by +the Align-Left, Align-Right, and Center radiobuttons on the toolbar of a +word-processor, for example. + .VE 8.4 .VS 8.4 .OP \-overrelief overRelief OverRelief diff --git a/mac/tkMacButton.c b/mac/tkMacButton.c index 8d9f57a..2c11dba 100644 --- a/mac/tkMacButton.c +++ b/mac/tkMacButton.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacButton.c,v 1.16 2002/06/17 10:54:29 drh Exp $ + * RCS: @(#) $Id: tkMacButton.c,v 1.17 2002/08/28 01:08:06 drh Exp $ */ #include "tkButton.h" @@ -227,8 +227,11 @@ TkpDisplayButton( if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { if (!TkMacHaveAppearance() || !hasImageOrBitmap) { - relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN - : butPtr->offRelief; + if (butPtr->flags & SELECTED) { + relief = TK_RELIEF_SUNKEN; + } else if (butPtr->overRelief != relief) { + relief = butPtr->offRelief; + } } } diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index bac7785..4a5887d 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixButton.c,v 1.9 2002/06/17 10:54:29 drh Exp $ + * RCS: @(#) $Id: tkUnixButton.c,v 1.10 2002/08/28 01:08:06 drh Exp $ */ #include "tkButton.h" @@ -115,13 +115,40 @@ TkpDisplayButton(clientData) /* * Override the relief specified for the button if this is a - * checkbutton or radiobutton and there's no indicator. + * checkbutton or radiobutton and there's no indicator. The new + * relief is as follows: + * If the button is select --> "sunken" + * If relief==overrelief --> relief + * Otherwise --> overrelief + * + * The effect we are trying to achieve is as follows: + * + * value mouse-over? --> relief + * ------- ------------ -------- + * off no flat + * off yes raised + * on no sunken + * on yes sunken + * + * This is accomplished by configuring the checkbutton or radiobutton + * like this: + * + * -indicatoron 0 -overrelief raised -offrelief flat + * + * Bindings (see library/button.tcl) will copy the -overrelief into + * -relief on mouseover. Hence, we can tell if we are in mouse-over by + * comparing relief against overRelief. This is an aweful kludge, but + * it gives use the desired behavior while keeping the code backwards + * compatible. */ relief = butPtr->relief; if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { - relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN - : butPtr->offRelief; + if (butPtr->flags & SELECTED) { + relief = TK_RELIEF_SUNKEN; + } else if (butPtr->overRelief != relief) { + relief = butPtr->offRelief; + } } offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin); diff --git a/win/tkWinButton.c b/win/tkWinButton.c index a2b063b..4ca5054 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinButton.c,v 1.17 2002/07/24 19:15:10 hobbs Exp $ + * RCS: @(#) $Id: tkWinButton.c,v 1.18 2002/08/28 01:08:06 drh Exp $ */ #define OEMRESOURCE @@ -383,13 +383,40 @@ TkpDisplayButton(clientData) /* * Override the relief specified for the button if this is a - * checkbutton or radiobutton and there's no indicator. + * checkbutton or radiobutton and there's no indicator. The new + * relief is as follows: + * If the button is select --> "sunken" + * If relief==overrelief --> relief + * Otherwise --> overrelief + * + * The effect we are trying to achieve is as follows: + * + * value mouse-over? --> relief + * ------- ------------ -------- + * off no flat + * off yes raised + * on no sunken + * on yes sunken + * + * This is accomplished by configuring the checkbutton or radiobutton + * like this: + * + * -indicatoron 0 -overrelief raised -offrelief flat + * + * Bindings (see library/button.tcl) will copy the -overrelief into + * -relief on mouseover. Hence, we can tell if we are in mouse-over by + * comparing relief against overRelief. This is an aweful kludge, but + * it gives use the desired behavior while keeping the code backwards + * compatible. */ relief = butPtr->relief; if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { - relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN - : butPtr->offRelief; + if (butPtr->flags & SELECTED) { + relief = TK_RELIEF_SUNKEN; + } else if (butPtr->overRelief != relief) { + relief = butPtr->offRelief; + } } /* -- cgit v0.12