From 90037ac50d2b47d8beb6aaa0d812489f6fd8f6a4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Jun 2002 10:54:29 +0000 Subject: Initial implementation of TIP #82: added the -offrelief option to checkbutton and radiobutton to allow those widgets to have a MS-Office look and feel. --- ChangeLog | 12 ++++++++++++ doc/checkbutton.n | 7 ++++++- doc/radiobutton.n | 7 ++++++- generic/tkButton.c | 6 +++++- generic/tkButton.h | 7 ++++++- mac/tkMacButton.c | 4 ++-- tests/button.test | 5 +++-- unix/tkUnixButton.c | 4 ++-- win/tkWinButton.c | 4 ++-- 9 files changed, 44 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index c88e100..098c563 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-06-17 D. Richard Hipp + + * doc/checkbutton.n: + * doc/radiobutton.n: + * generic/tkButton.c: + * generic/tkButton.h: + * mac/tkMacButton.c: + * tests/button.test: + * unix/tkUnixButton.c: + * win/tkWinButton.c: Implementation of TIP#82 - Added the + -offrelief option to checkbutton and radiobutton. + 2002-06-14 Mo DeJong * generic/tkWindow.c (Tk_DestroyWindow): Set the pathName diff --git a/doc/checkbutton.n b/doc/checkbutton.n index 46e0e29..9f762bd 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.4 2000/08/25 06:58:32 ericm Exp $ +'\" RCS: @(#) $Id: checkbutton.n,v 1.5 2002/06/17 10:54:29 drh Exp $ '\" .so man.macros .TH checkbutton n 4.4 Tk "Tk Built-In Commands" @@ -43,6 +43,11 @@ Specifies whether or not the indicator should be drawn. Must be a proper boolean value. If false, the \fBrelief\fR option is ignored and the widget's relief is always sunken if the widget is 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". +.VE 8.4 .OP \-offvalue offValue Value Specifies value to store in the button's associated variable whenever this button is deselected. Defaults to ``0''. diff --git a/doc/radiobutton.n b/doc/radiobutton.n index face3e2..5c3b17a 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.4 2000/08/25 06:58:32 ericm Exp $ +'\" RCS: @(#) $Id: radiobutton.n,v 1.5 2002/06/17 10:54:29 drh Exp $ '\" .so man.macros .TH radiobutton n 4.4 Tk "Tk Built-In Commands" @@ -54,6 +54,11 @@ whenever the widget is selected. If specified as an empty string then no special color is used for 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". +.VE 8.4 +.VS 8.4 .OP \-overrelief overRelief OverRelief Specifies an alternative relief for the radiobutton, to be used when the mouse cursor is over the widget. This option can be used to make diff --git a/generic/tkButton.c b/generic/tkButton.c index fc9eab1..429916f 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkButton.c,v 1.17 2002/05/26 09:25:56 pspjuth Exp $ + * RCS: @(#) $Id: tkButton.c,v 1.18 2002/06/17 10:54:29 drh Exp $ */ #include "tkButton.h" @@ -310,6 +310,8 @@ static Tk_OptionSpec checkbuttonOptionSpecs[] = { DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn), 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief", + DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0}, {TK_OPTION_STRING, "-offvalue", "offValue", "Value", DEF_BUTTON_OFF_VALUE, Tk_Offset(TkButton, offValuePtr), -1, 0, 0, 0}, {TK_OPTION_STRING, "-onvalue", "onValue", "Value", @@ -418,6 +420,8 @@ static Tk_OptionSpec radiobuttonOptionSpecs[] = { 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief", + DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0}, {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief", DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief), TK_OPTION_NULL_OK, 0, 0}, diff --git a/generic/tkButton.h b/generic/tkButton.h index 6469d46..be195c6 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -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: tkButton.h,v 1.8 2000/11/22 01:49:37 ericm Exp $ + * RCS: @(#) $Id: tkButton.h,v 1.9 2002/06/17 10:54:29 drh Exp $ */ #ifndef _TKBUTTON @@ -120,6 +120,11 @@ typedef struct { * effect for the border, such as * TK_RELIEF_RAISED, to be used when the mouse * is over the button. */ + int offRelief; /* Value of -offrelief option: specifies a 3-d + * effect for the border, such as + * TK_RELIEF_RAISED, to be used when a + * checkbutton or radiobutton without + * indicator is off */ Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option: * specifies width in pixels of highlight to * draw around widget when it has the focus. diff --git a/mac/tkMacButton.c b/mac/tkMacButton.c index 980a778..8d9f57a 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.15 2001/11/23 02:05:37 das Exp $ + * RCS: @(#) $Id: tkMacButton.c,v 1.16 2002/06/17 10:54:29 drh Exp $ */ #include "tkButton.h" @@ -228,7 +228,7 @@ TkpDisplayButton( if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { if (!TkMacHaveAppearance() || !hasImageOrBitmap) { relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN - : TK_RELIEF_RAISED; + : butPtr->offRelief; } } diff --git a/tests/button.test b/tests/button.test index 67f019b..ed0b7ee 100644 --- a/tests/button.test +++ b/tests/button.test @@ -7,7 +7,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: button.test,v 1.10 2001/11/17 22:44:04 hobbs Exp $ +# RCS: @(#) $Id: button.test,v 1.11 2002/06/17 10:54:29 drh Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -85,6 +85,7 @@ foreach test { {-indicatoron yes 1 no_way {expected boolean value but got "no_way"} {0 0 1 1}} {-justify right right bogus {bad justification "bogus": must be left, right, or center} {1 1 1 1}} + {-offrelief flat flat 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken} {0 0 1 1}} {-offvalue lousy lousy {} {} {0 0 1 0}} {-offvalue fantastic fantastic {} {} {0 0 1 0}} {-overrelief "" "" 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken} {0 1 1 1}} @@ -226,7 +227,7 @@ test button-4.13 {ButtonWidgetCmd procedure, "cget" option} { } {1 {unknown option "-onvalue"}} test button-4.14 {ButtonWidgetCmd procedure, "configure" option} { llength [.c configure] -} {38} +} {39} test button-4.15 {ButtonWidgetCmd procedure, "configure" option} { list [catch {.b configure -gorp} msg] $msg } {1 {unknown option "-gorp"}} diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 46dff22..bac7785 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.8 2000/11/22 01:49:38 ericm Exp $ + * RCS: @(#) $Id: tkUnixButton.c,v 1.9 2002/06/17 10:54:29 drh Exp $ */ #include "tkButton.h" @@ -121,7 +121,7 @@ TkpDisplayButton(clientData) relief = butPtr->relief; if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN - : TK_RELIEF_RAISED; + : butPtr->offRelief; } offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin); diff --git a/win/tkWinButton.c b/win/tkWinButton.c index a9f19d5..8c86197 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.15 2002/04/05 08:43:22 hobbs Exp $ + * RCS: @(#) $Id: tkWinButton.c,v 1.16 2002/06/17 10:54:29 drh Exp $ */ #define OEMRESOURCE @@ -387,7 +387,7 @@ TkpDisplayButton(clientData) relief = butPtr->relief; if ((butPtr->type >= TYPE_CHECK_BUTTON) && !butPtr->indicatorOn) { relief = (butPtr->flags & SELECTED) ? TK_RELIEF_SUNKEN - : TK_RELIEF_RAISED; + : butPtr->offRelief; } /* -- cgit v0.12