diff options
author | ericm <ericm> | 2000-05-17 21:17:19 (GMT) |
---|---|---|
committer | ericm <ericm> | 2000-05-17 21:17:19 (GMT) |
commit | 54e6352675121c47a41ffafce8b02911986cac96 (patch) | |
tree | cc806cc6c8cbd3daf45e4f418ada919e3ab812e0 | |
parent | 2adfe2dab62fa99750852c0a35ff3dbedb810adc (diff) | |
download | tk-54e6352675121c47a41ffafce8b02911986cac96.zip tk-54e6352675121c47a41ffafce8b02911986cac96.tar.gz tk-54e6352675121c47a41ffafce8b02911986cac96.tar.bz2 |
* doc/SetOptions.3: Added information about TK_OPTION_NULL_OK with
TK_OPTION_RELIEF.
* win/tkWinButton.c: Removed bits about TK_RELIEF_LINK.
* tests/button.test: Added tests for -overrelief; removed tests
for -relief link.
* mac/tkMacButton.c: Removed bits about TK_RELIEF_LINK.
* generic/tkOldConfig.c: Removed bits about TK_RELIEF_LINK.
* generic/tkConfig.c: Removed bits about TK_RELIEF_LINK; added
support for TK_OPTION_NULL_OK for TK_OPTION_RELIEF.
* library/button.tcl: Added binding support for -overrelief.
* generic/tk3d.c (Tk_GetRelief): Added branch for TK_RELIEF_NULL.
* generic/tkButton.c: Added -overrelief option; removed
Enter/Leave EventProc masks and handlers.
* generic/tk.h: Added TK_RELIEF_NULL definition, removed
TK_RELIEF_LINK.
* mac/tkMacDefault.h (DEF_BUTTON_OVER_RELIEF):
* win/tkWinDefault.h (DEF_BUTTON_OVER_RELIEF):
* unix/tkUnixDefault.h (DEF_BUTTON_OVER_RELIEF): Added default
value for the -overrelief option.
-rw-r--r-- | ChangeLog | 37 | ||||
-rw-r--r-- | doc/SetOptions.3 | 6 | ||||
-rw-r--r-- | doc/button.n | 15 | ||||
-rw-r--r-- | generic/tk.h | 9 | ||||
-rw-r--r-- | generic/tk3d.c | 6 | ||||
-rw-r--r-- | generic/tkButton.c | 15 | ||||
-rw-r--r-- | generic/tkButton.h | 9 | ||||
-rw-r--r-- | generic/tkConfig.c | 33 | ||||
-rw-r--r-- | generic/tkOldConfig.c | 27 | ||||
-rw-r--r-- | library/button.tcl | 107 | ||||
-rw-r--r-- | mac/tkMacButton.c | 15 | ||||
-rw-r--r-- | mac/tkMacDefault.h | 3 | ||||
-rw-r--r-- | tests/button.test | 19 | ||||
-rw-r--r-- | unix/tkUnixButton.c | 16 | ||||
-rw-r--r-- | unix/tkUnixDefault.h | 3 | ||||
-rw-r--r-- | win/tkWinButton.c | 16 | ||||
-rw-r--r-- | win/tkWinDefault.h | 3 |
17 files changed, 182 insertions, 157 deletions
@@ -1,3 +1,40 @@ +2000-05-17 Eric Melski <ericm@scriptics.com> + + Overall change: changed implementation of "link" relief for + buttons. Instead of a new relief style (-relief link), there is a + new option, -overrelief, which if set is used when the mouse is + over the button. + + * doc/SetOptions.3: Added information about TK_OPTION_NULL_OK with + TK_OPTION_RELIEF. + + * win/tkWinButton.c: Removed bits about TK_RELIEF_LINK. + + * tests/button.test: Added tests for -overrelief; removed tests + for -relief link. + + * mac/tkMacButton.c: Removed bits about TK_RELIEF_LINK. + + * generic/tkOldConfig.c: Removed bits about TK_RELIEF_LINK. + + * generic/tkConfig.c: Removed bits about TK_RELIEF_LINK; added + support for TK_OPTION_NULL_OK for TK_OPTION_RELIEF. + + * library/button.tcl: Added binding support for -overrelief. + + * generic/tk3d.c (Tk_GetRelief): Added branch for TK_RELIEF_NULL. + + * generic/tkButton.c: Added -overrelief option; removed + Enter/Leave EventProc masks and handlers. + + * generic/tk.h: Added TK_RELIEF_NULL definition, removed + TK_RELIEF_LINK. + + * mac/tkMacDefault.h (DEF_BUTTON_OVER_RELIEF): + * win/tkWinDefault.h (DEF_BUTTON_OVER_RELIEF): + * unix/tkUnixDefault.h (DEF_BUTTON_OVER_RELIEF): Added default + value for the -overrelief option. + 2000-05-16 Eric Melski <ericm@scriptics.com> * win/tkWinMenu.c (ReconfigureWindowsMenu): Added code to add the diff --git a/doc/SetOptions.3 b/doc/SetOptions.3 index 4a6a1a4..8393085 100644 --- a/doc/SetOptions.3 +++ b/doc/SetOptions.3 @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: SetOptions.3,v 1.2 1999/04/16 01:51:08 stanton Exp $ +'\" RCS: @(#) $Id: SetOptions.3,v 1.3 2000/05/17 21:17:19 ericm Exp $ '\" .so man.macros .TH Tk_SetOptions 3 8.1 Tk "Tk Library Procedures" @@ -411,7 +411,9 @@ See \fBOBJOFFSET VS. INTERNALOFFSET\fR below for details. \fBTK_OPTION_RELIEF\fR The value must be standard relief such as \fBraised\fR. The internal form is an integer relief value such as -TK_RELIEF_RAISED. +TK_RELIEF_RAISED. This option type supports the TK_OPTION_NULL_OK +flag; if the empty string is specified as the value for the option, +the integer relief value is set to TK_RELIEF_NULL. .TP \fBTK_OPTION_STRING\fR The value may be any string. The internal form is a (char *) pointer diff --git a/doc/button.n b/doc/button.n index 3cddf77..1d106cc 100644 --- a/doc/button.n +++ b/doc/button.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: button.n,v 1.4 2000/05/13 00:39:06 ericm Exp $ +'\" RCS: @(#) $Id: button.n,v 1.5 2000/05/17 21:17:20 ericm Exp $ '\" .so man.macros .TH button n 4.4 Tk "Tk Built-In Commands" @@ -63,12 +63,13 @@ for text it is in lines of text. If this option isn't specified, the button's desired height is computed from the size of the image or bitmap or text being displayed in it. .VS 8.4 -.OP \-relief relief Relief -Specifies a relief for the button. In addition to the standard relief -styles available to most widgets, buttons support the \fBlink\fR -relief style. When using this relief style, buttons will have a -raised relief when they are active (when the mouse cursor is over the -button), and a flat relief otherwise. +.OP \-overrelief overRelief OverRelief +Specifies an alternative relief for the button, to be used when the +mouse cursor is over the widget. This option can be used to make +toolbar buttons, by configuring \fB\-relief flat \-overrelief +raised\fR. If the value of this option is the empty string, then no +alternative relief is used when the mouse cursor is over the button. +The empty string is the default value. .VE 8.4 .OP \-state state State Specifies one of three states for the button: \fBnormal\fR, \fBactive\fR, diff --git a/generic/tk.h b/generic/tk.h index 62fab06..3b58cdd 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tk.h,v 1.42 2000/05/13 00:39:07 ericm Exp $ + * RCS: @(#) $Id: tk.h,v 1.43 2000/05/17 21:17:20 ericm Exp $ */ #ifndef _TK @@ -204,9 +204,6 @@ typedef struct Tk_OptionSpec { #define TK_OPTION_NULL_OK (1 << 0) #define TK_OPTION_DONT_SET_DEFAULT (1 << 3) -/* This widget allows the link relief */ -#define TK_OPTION_LINK_OK (1 << 6) - /* * Macro to use to fill in "offset" fields of the Tk_OptionSpec. * struct. Computes number of bytes from beginning of structure @@ -368,8 +365,6 @@ typedef enum { #define TK_CONFIG_MONO_ONLY (1 << 2) #define TK_CONFIG_DONT_SET_DEFAULT (1 << 3) #define TK_CONFIG_OPTION_SPECIFIED (1 << 4) -/* This widget allows the link relief */ -#define TK_CONFIG_LINK_OK (1 << 6) #define TK_CONFIG_USER_BIT 0x100 #endif /* __NO_OLD_CONFIG */ @@ -439,13 +434,13 @@ typedef enum { * Relief values returned by Tk_GetRelief: */ +#define TK_RELIEF_NULL -1 #define TK_RELIEF_FLAT 0 #define TK_RELIEF_GROOVE 1 #define TK_RELIEF_RAISED 2 #define TK_RELIEF_RIDGE 3 #define TK_RELIEF_SOLID 4 #define TK_RELIEF_SUNKEN 5 -#define TK_RELIEF_LINK 6 /* * "Which" argument values for Tk_3DBorderGC: diff --git a/generic/tk3d.c b/generic/tk3d.c index 98375f6..e6ba11a 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tk3d.c,v 1.9 2000/05/13 00:39:07 ericm Exp $ + * RCS: @(#) $Id: tk3d.c,v 1.10 2000/05/17 21:17:20 ericm Exp $ */ #include "tk3d.h" @@ -720,8 +720,8 @@ Tk_NameOfRelief(relief) return "ridge"; } else if (relief == TK_RELIEF_SOLID) { return "solid"; - } else if (relief == TK_RELIEF_LINK) { - return "link"; + } else if (relief == TK_RELIEF_NULL) { + return ""; } else { return "unknown relief"; } diff --git a/generic/tkButton.c b/generic/tkButton.c index e3c9d86..8f70e3d 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.6 2000/05/13 00:39:07 ericm Exp $ + * RCS: @(#) $Id: tkButton.c,v 1.7 2000/05/17 21:17:20 ericm Exp $ */ #include "tkButton.h" @@ -198,6 +198,9 @@ static Tk_OptionSpec buttonOptionSpecs[] = { TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0}, + {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief", + DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief), + TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", DEF_BUTTON_PADX, Tk_Offset(TkButton, padXPtr), Tk_Offset(TkButton, padX), 0, 0, 0}, @@ -206,7 +209,7 @@ static Tk_OptionSpec buttonOptionSpecs[] = { Tk_Offset(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief), - TK_OPTION_LINK_OK, 0, 0}, + 0, 0, 0}, {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", DEF_BUTTON_REPEAT_DELAY, -1, Tk_Offset(TkButton, repeatDelay), 0, 0, 0}, @@ -713,7 +716,7 @@ ButtonCreate(clientData, interp, objc, objv, type) butPtr->flags = 0; Tk_CreateEventHandler(butPtr->tkwin, - ExposureMask|StructureNotifyMask|FocusChangeMask|EnterWindowMask|LeaveWindowMask, + ExposureMask|StructureNotifyMask|FocusChangeMask, ButtonEventProc, (ClientData) butPtr); if (Tk_InitOptions(interp, (char *) butPtr, optionTable, tkwin) @@ -1397,12 +1400,6 @@ ButtonEventProc(clientData, eventPtr) goto redraw; } } - } else if (eventPtr->type == EnterNotify) { - butPtr->flags |= MOUSE_IN_BUTTON; - goto redraw; - } else if (eventPtr->type == LeaveNotify) { - butPtr->flags &= ~MOUSE_IN_BUTTON; - goto redraw; } return; diff --git a/generic/tkButton.h b/generic/tkButton.h index cb774f9..97cc1f0 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.6 2000/05/13 00:39:07 ericm Exp $ + * RCS: @(#) $Id: tkButton.h,v 1.7 2000/05/17 21:17:20 ericm Exp $ */ #ifndef _TKBUTTON @@ -116,6 +116,10 @@ typedef struct { int relief; /* Value of -relief option: specifies 3-d * effect for border, such as * TK_RELIEF_RAISED. */ + int overRelief; /* Value of -overrelief option: specifies a 3-d + * effect for the border, such as + * TK_RELIEF_RAISED, to be used when the mouse + * is over the button. */ Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option: * specifies width in pixels of highlight to * draw around widget when it has the focus. @@ -273,15 +277,12 @@ typedef struct { * BUTTON_DELETED: Non-zero needs that this button has been * deleted, or is in the process of being * deleted. - * MOUSE_IN_BUTTON: Non-zero means that the mouse is currently - * over the button. */ #define REDRAW_PENDING (1 << 0) #define SELECTED (1 << 1) #define GOT_FOCUS (1 << 2) #define BUTTON_DELETED (1 << 3) -#define MOUSE_IN_BUTTON (1 << 4) /* * Declaration of variables shared between the files in the button module. */ diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 5739a7e..0f2bea5 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.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: tkConfig.c,v 1.8 2000/05/10 00:09:39 ericm Exp $ + * RCS: @(#) $Id: tkConfig.c,v 1.9 2000/05/17 21:17:20 ericm Exp $ */ /* @@ -804,34 +804,15 @@ DoObjConfig(interp, recordPtr, optionPtr, valuePtr, tkwin, savedOptionPtr) } case TK_OPTION_RELIEF: { int new; - char *valueStr; - - if (Tk_GetReliefFromObj(interp, valuePtr, &new) != TCL_OK) { - /* - * In order that error messages be handled properly, we let - * GetReliefFromObj do the first pass check on the relief - * string. If it fails there, and the option spec doesn't - * allow for LINK relief, return an error. If the option spec - * does allow LINK relief, see if the string matches "link". - */ - if ((specPtr->flags & TK_OPTION_LINK_OK) == 0) { + + if (nullOK && ObjectIsEmpty(valuePtr)) { + valuePtr = NULL; + new = TK_RELIEF_NULL; + } else { + if (Tk_GetReliefFromObj(interp, valuePtr, &new) != TCL_OK) { return TCL_ERROR; - } else { - valueStr = Tcl_GetString(valuePtr); - if (valueStr[0] == 'l' && strcmp(valueStr, "link") == 0) { - new = TK_RELIEF_LINK; - Tcl_ResetResult(interp); - } else { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad relief \"", - valueStr, "\": must be flat, groove, link, " - "raised, ridge, solid, or sunken", - (char *)NULL); - return TCL_ERROR; - } } } - if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = new; diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 3a373c0..61b1258 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.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: tkOldConfig.c,v 1.8 2000/05/13 00:39:07 ericm Exp $ + * RCS: @(#) $Id: tkOldConfig.c,v 1.9 2000/05/17 21:17:21 ericm Exp $ */ #include "tkPort.h" @@ -483,32 +483,9 @@ DoConfig(interp, tkwin, specPtr, value, valueIsUid, widgRec) } case TK_CONFIG_RELIEF: uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); - /* - * In order that error messages be handled properly, we let - * GetRelief do the first pass check on the relief - * string. If it fails there, and the option spec doesn't - * allow for LINK relief, return an error. If the option spec - * does allow LINK relief, see if the string matches "link". - */ - if (Tk_GetRelief(interp, uid, (int *) ptr) != TCL_OK) { - if ((specPtr->specFlags & TK_CONFIG_LINK_OK) == 0) { - return TCL_ERROR; - } else { - if (uid[0] == 'l' && strcmp(uid, "link") == 0) { - *ptr = TK_RELIEF_LINK; - Tcl_ResetResult(interp); - } else { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "bad relief \"", - uid, "\": must be flat, groove, link, " - "raised, ridge, solid, or sunken", - (char *)NULL); - return TCL_ERROR; - } - } + return TCL_ERROR; } - break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: { diff --git a/library/button.tcl b/library/button.tcl index 0184648..fddccc6 100644 --- a/library/button.tcl +++ b/library/button.tcl @@ -4,7 +4,7 @@ # checkbutton, and radiobutton widgets and provides procedures # that help in implementing those bindings. # -# RCS: @(#) $Id: button.tcl,v 1.7 2000/05/13 00:39:08 ericm Exp $ +# RCS: @(#) $Id: button.tcl,v 1.8 2000/05/17 21:17:21 ericm Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. @@ -142,9 +142,17 @@ if {[string match "windows" $tcl_platform(platform)]} { proc tkButtonEnter w { global tkPriv - if {[string compare [$w cget -state] "disabled"] \ - && [string equal $tkPriv(buttonWindow) $w]} { - $w configure -state active -relief sunken + if {[string compare [$w cget -state] "disabled"] } { + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + + if {[string equal $tkPriv(buttonWindow) $w]} { + $w configure -state active -relief sunken + } elseif { [string compare [$w cget -overrelief] ""] } { + set tkPriv(relief) [$w cget -relief] + $w configure -relief [$w cget -overrelief] + } } set tkPriv(window) $w } @@ -164,9 +172,15 @@ proc tkButtonLeave w { if {[string compare [$w cget -state] "disabled"]} { $w configure -state normal } - if {[string equal $tkPriv(buttonWindow) $w]} { + + # Restore the original button relief if the mouse button is down + # or there is an -overrelief value. + + if {[string equal $tkPriv(buttonWindow) $w] || \ + [string compare [$w cget -overrelief] ""] } { $w configure -relief $tkPriv(relief) } + set tkPriv(window) "" } @@ -199,7 +213,14 @@ proc tkCheckRadioEnter w { proc tkButtonDown w { global tkPriv - set tkPriv(relief) [$w cget -relief] + # Only save the button's relief if it has no -overrelief value. If there + # is an overrelief setting, tkPriv(relief) will already have been set, and + # the current value of the -relief option will be incorrect. + + if { [string equal [$w cget -overrelief] ""] } { + set tkPriv(relief) [$w cget -relief] + } + if {[string compare [$w cget -state] "disabled"]} { set tkPriv(buttonWindow) $w $w configure -relief sunken -state active @@ -244,7 +265,21 @@ proc tkButtonUp w { global tkPriv if {[string equal $tkPriv(buttonWindow) $w]} { set tkPriv(buttonWindow) "" - $w configure -relief $tkPriv(relief) + # Restore the button's relief. If there is no overrelief, the + # button relief goes back to its original value. If there is an + # overrelief, the relief goes to the overrelief (since the cursor is + # still over the button). + + set relief [$w cget -overrelief] + if { [string equal $relief ""] } { + set relief $tkPriv(relief) + } + $w configure -relief $relief + + # Clean up the after event from the auto-repeater + + after cancel $tkPriv(afterId) + if {[string equal $tkPriv(window) $w] && [string compare [$w cget -state] "disabled"]} { $w configure -state normal @@ -278,10 +313,18 @@ proc tkButtonEnter {w} { global tkPriv if {[string compare [$w cget -state] "disabled"]} { $w configure -state active + + # If the mouse button is down, set the relief to sunken on entry. + # Overwise, if there's an -overrelief value, set the relief to that. + if {[string equal $tkPriv(buttonWindow) $w]} { $w configure -state active -relief sunken + } elseif { [string compare [$w cget -overrelief] ""] } { + set tkPriv(relief) [$w cget -relief] + $w configure -relief [$w cget -overrelief] } } + set tkPriv(window) $w } @@ -300,9 +343,15 @@ proc tkButtonLeave w { if {[string compare [$w cget -state] "disabled"]} { $w configure -state normal } - if {[string equal $tkPriv(buttonWindow) $w]} { + + # Restore the original button relief if the mouse button is down + # or there is an -overrelief value. + + if {[string equal $tkPriv(buttonWindow) $w] || \ + [string compare [$w cget -overrelief] ""] } { $w configure -relief $tkPriv(relief) } + set tkPriv(window) "" } @@ -317,7 +366,15 @@ proc tkButtonLeave w { proc tkButtonDown w { global tkPriv - set tkPriv(relief) [$w cget -relief] + + # Only save the button's relief if it has no -overrelief value. If there + # is an overrelief setting, tkPriv(relief) will already have been set, and + # the current value of the -relief option will be incorrect. + + if { [string equal [$w cget -overrelief] ""] } { + set tkPriv(relief) [$w cget -relief] + } + if {[string compare [$w cget -state] "disabled"]} { set tkPriv(buttonWindow) $w $w configure -relief sunken @@ -344,8 +401,21 @@ proc tkButtonUp w { global tkPriv if {[string equal $w $tkPriv(buttonWindow)]} { set tkPriv(buttonWindow) "" - $w configure -relief $tkPriv(relief) + + # Restore the button's relief. If there is no overrelief, the + # button relief goes back to its original value. If there is an + # overrelief, the relief goes to the overrelief (since the cursor is + # still over the button). + + set relief [$w cget -overrelief] + if { [string equal $relief ""] } { + set relief $tkPriv(relief) + } + $w configure -relief $relief + + # Clean up the after event from the auto-repeater after cancel $tkPriv(afterId) + if {[string equal $w $tkPriv(window)] \ && [string compare [$w cget -state] "disabled"]} { @@ -377,8 +447,11 @@ if {[string match "macintosh" $tcl_platform(platform)]} { proc tkButtonEnter {w} { global tkPriv if {[string compare [$w cget -state] "disabled"]} { - if {[string equal $w $tkPriv(buttonWindow)]} { + if {[string equal $w $tkPriv(buttonWindow)]} { $w configure -state active + } elseif { [string compare [$w cget -overrelief] ""] } { + set tkPriv(relief) [$w cget -relief] + $w configure -relief [$w cget -overrelief] } } set tkPriv(window) $w @@ -399,6 +472,9 @@ proc tkButtonLeave w { if {[string equal $w $tkPriv(buttonWindow)]} { $w configure -state normal } + if { [string compare [$w cget -overrelief] ""] } { + $w configure -relief $tkPriv(relief) + } set tkPriv(window) "" } @@ -413,6 +489,7 @@ proc tkButtonLeave w { proc tkButtonDown w { global tkPriv + if {[string compare [$w cget -state] "disabled"]} { set tkPriv(buttonWindow) $w $w configure -state active @@ -440,6 +517,14 @@ proc tkButtonUp w { if {[string equal $w $tkPriv(buttonWindow)]} { $w configure -state normal set tkPriv(buttonWindow) "" + + if { [string compare [$w cget -overrelief] ""] } { + $w configure -relief [$w cget -overrelief] + } + + # Clean up the after event from the auto-repeater + after cancel $tkPriv(afterId) + if {[string equal $w $tkPriv(window)] && [string compare [$w cget -state] "disabled"]} { # Only invoke the command if it wasn't already invoked by the diff --git a/mac/tkMacButton.c b/mac/tkMacButton.c index b726c82..1eb4231 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.12 2000/05/13 00:39:08 ericm Exp $ + * RCS: @(#) $Id: tkMacButton.c,v 1.13 2000/05/17 21:17:21 ericm Exp $ */ #include "tkButton.h" @@ -233,19 +233,6 @@ TkpDisplayButton( } /* - * LINK relief means that the button has a raised relief when it is - * active, and a flat relief otherwise (like toolbar buttons). It - * is supported for true buttons only. - */ - - if ((butPtr->type == TYPE_BUTTON) && butPtr->relief == TK_RELIEF_LINK) { - if ((butPtr->flags & MOUSE_IN_BUTTON) == MOUSE_IN_BUTTON) { - relief = TK_RELIEF_RAISED; - } else { - relief = TK_RELIEF_FLAT; - } - } - /* * See the comment in UpdateControlColors as to why we use the * highlightbackground for the border of Macintosh buttons. */ diff --git a/mac/tkMacDefault.h b/mac/tkMacDefault.h index 1d7f010..42cfe76 100644 --- a/mac/tkMacDefault.h +++ b/mac/tkMacDefault.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacDefault.h,v 1.6 2000/05/14 20:45:38 ericm Exp $ + * RCS: @(#) $Id: tkMacDefault.h,v 1.7 2000/05/17 21:17:21 ericm Exp $ */ #ifndef _TKMACDEFAULT @@ -72,6 +72,7 @@ #define DEF_BUTTON_JUSTIFY "center" #define DEF_BUTTON_OFF_VALUE "0" #define DEF_BUTTON_ON_VALUE "1" +#define DEF_BUTTON_OVER_RELIEF "" #define DEF_BUTTON_PADX "7" #define DEF_LABCHKRAD_PADX "1" #define DEF_BUTTON_PADY "3" diff --git a/tests/button.test b/tests/button.test index 67e0a3b..1c34c5c 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.7 2000/05/13 00:39:09 ericm Exp $ +# RCS: @(#) $Id: button.test,v 1.8 2000/05/17 21:17:22 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { source [file join [pwd] [file dirname [info script]] defs.tcl] @@ -87,10 +87,12 @@ foreach test { {-justify right right bogus {bad justification "bogus": must be left, right, or center} {1 1 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 0 0}} {-padx 12m 12m 420x {bad screen distance "420x"} {1 1 1 1}} {-pady 12m 12m 420x {bad screen distance "420x"} {1 1 1 1}} {-repeatdelay 100 100 foo {expected integer but got "foo"} {0 1 0 0}} {-repeatinterval 100 100 foo {expected integer but got "foo"} {0 1 0 0}} + {-relief flat flat 1.5 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken} {1 1 1 1}} {-selectcolor #110022 #110022 bogus {unknown color name "bogus"} {0 0 1 1}} {-selectimage image1 image1 bogus {image "bogus" doesn't exist} {0 0 1 1}} {-state normal normal bogus {bad state "bogus": must be active, disabled, or normal} {1 1 1 1}} @@ -128,21 +130,6 @@ foreach test { test button-1.$i {configuration options} { .c configure -selectcolor {} } {} -test button-1.[incr i] {configuration options} { - list [catch {.l configure -relief 1.5} msg] $msg -} [list 1 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}] -test button-1.[incr i] {configuration options} { - list [catch {.c configure -relief 1.5} msg] $msg -} [list 1 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}] -test button-1.[incr i] {configuration options} { - list [catch {.r configure -relief 1.5} msg] $msg -} [list 1 {bad relief "1.5": must be flat, groove, raised, ridge, solid, or sunken}] -test button-1.[incr i] {configuration options} { - list [catch {.b configure -relief 1.5} msg] $msg -} [list 1 {bad relief "1.5": must be flat, groove, link, raised, ridge, solid, or sunken}] -test button-1.[incr i] {configuration options} { - list [catch {.b configure -relief link} msg] $msg [.b cget -relief] -} [list 0 {} link] test button-3.1 {ButtonCreate - not enough cd ../unix } { diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index ce9ffac..bad8d8a 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.5 2000/05/13 00:39:09 ericm Exp $ + * RCS: @(#) $Id: tkUnixButton.c,v 1.6 2000/05/17 21:17:22 ericm Exp $ */ #include "tkButton.h" @@ -125,20 +125,6 @@ TkpDisplayButton(clientData) : TK_RELIEF_RAISED; } - /* - * LINK relief means that the button has a raised relief when it is - * active, and a flat relief otherwise (like toolbar buttons). It - * is supported for true buttons only. - */ - - if ((butPtr->type == TYPE_BUTTON) && butPtr->relief == TK_RELIEF_LINK) { - if ((butPtr->flags & MOUSE_IN_BUTTON) == MOUSE_IN_BUTTON) { - relief = TK_RELIEF_RAISED; - } else { - relief = TK_RELIEF_FLAT; - } - } - offset = (butPtr->type == TYPE_BUTTON) && !Tk_StrictMotif(butPtr->tkwin); /* diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index 345b943..312e579 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnixDefault.h,v 1.6 2000/05/14 20:45:39 ericm Exp $ + * RCS: @(#) $Id: tkUnixDefault.h,v 1.7 2000/05/17 21:17:22 ericm Exp $ */ #ifndef _TKUNIXDEFAULT @@ -70,6 +70,7 @@ #define DEF_BUTTON_JUSTIFY "center" #define DEF_BUTTON_OFF_VALUE "0" #define DEF_BUTTON_ON_VALUE "1" +#define DEF_BUTTON_OVER_RELIEF "" #define DEF_BUTTON_PADX "3m" #define DEF_LABCHKRAD_PADX "1" #define DEF_BUTTON_PADY "1m" diff --git a/win/tkWinButton.c b/win/tkWinButton.c index f40e9ba..b7acb47 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.8 2000/05/13 00:39:09 ericm Exp $ + * RCS: @(#) $Id: tkWinButton.c,v 1.9 2000/05/17 21:17:22 ericm Exp $ */ #define OEMRESOURCE @@ -391,20 +391,6 @@ TkpDisplayButton(clientData) } /* - * LINK relief means that the button has a raised relief when it is - * active, and a flat relief otherwise (like toolbar buttons). It - * is supported for true buttons only. - */ - - if ((butPtr->type == TYPE_BUTTON) && butPtr->relief == TK_RELIEF_LINK) { - if ((butPtr->flags & MOUSE_IN_BUTTON) == MOUSE_IN_BUTTON) { - relief = TK_RELIEF_RAISED; - } else { - relief = TK_RELIEF_FLAT; - } - } - - /* * Compute width of default ring and offset for pushed buttons. */ diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 79a1771..1c59512 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.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: tkWinDefault.h,v 1.6 2000/05/14 20:45:39 ericm Exp $ + * RCS: @(#) $Id: tkWinDefault.h,v 1.7 2000/05/17 21:17:23 ericm Exp $ */ #ifndef _TKWINDEFAULT @@ -76,6 +76,7 @@ #define DEF_BUTTON_JUSTIFY "center" #define DEF_BUTTON_OFF_VALUE "0" #define DEF_BUTTON_ON_VALUE "1" +#define DEF_BUTTON_OVER_RELIEF "" #define DEF_BUTTON_PADX "1" #define DEF_LABCHKRAD_PADX "1" #define DEF_BUTTON_PADY "1" |